My changes to .gitignore are not causing git to add some files previously ignored
.gitignore had this in it
!import/
import/*
!import/*.foo
To have all but the foo files tracked. This worked well. However, I want all the files in import/ to be tracked now, so I commented those lines of .gitignore.
I now get this
craig#ubuntu-dev:<workspace>$ cd import
craig#ubuntu-dev:<workspace>/import$ git add .
craig#ubuntu-dev:<workspace>/import$ git commit -m "comment"
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
I am a newbie. Am I using git incorrectly or is there something I have to tell it to re-include the .gitignore or ?
Cheers
This works by explicitly telling git to import these.
I presume git continues to track them after this.
git add import/*
Related
I'm trying to commit my project using git commit -m "First.". But throw this error, remembering that I wrote git init.
Other version control systems simply commit whatever files have been changed. Git is different. You must first build the commit by adding them to the staging area with git add. Then you git commit what has been added. This allows you to do some very powerful things, like split big changes into multiple commits.
For the above, add everything with git add . then you can commit. Though you probably want to add .vscode, tmp/, *.lock and any other temporary files and directories to your .gitignore file.
For more, please read Git Basics - Recording Changes to the Repository.
New to using github in VS Code and accidentally did git init on a high level folder when in fact i meant a low level sub folder. I've tried to do everything i can to un-assign this folder as it has over 5000 items in (.js libraries etc!) but can't seem to google the right solution. If i check git status in the terminal window i get
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
FreeCodeCamp/
folder1/
Test web/
Web cheat sheet.html
index.html
my_profile_pic-min.jpg
my_profile_pic.jpg
folder2/
bio/
blog/
nothing added to commit but untracked files present (use "git add" to track)
PS D:\Web Design>
Not really sure how to remove/change the master folder to the freecodecamp sub folder.
All help welcome.
Thanks.
You can simply delete the .git directory in the high level directory to stop git tracking there, and then do git init again in the appropriate sub-directory to initialize that as a git repository.
Sadly I've been at it for 3 hours trying to commit my assignment which is a single folder... This is my private github repo
I can't drag the folder since it's limited at 100 files apparently there's like 4000 in my folder?
What I've done is:
$ git clone githuburl
(i now dragged my assignment folder to this repo in my own pc)
$ git add assignmentfolder (pages)
$ git commit -m "first commit"
$ git push origin master
And as you can see it straight up ignored every single file and just committed the folder name?
I think the proper way to do this is:
git clone githuburl
cd githubfoldername
then move all your files there
add a .gitignore file there and exclude node_modules and everything else that has to do with caching and external packages because you don't need them in your repo. Everyone who is going to use your code will be able to install the packages as you did. Just make sure you include the:
packages.json if you used npm
or yarn.lock if you used yarn
Then you can safely
git add --all
git commit -m "your message"
This way you will avoid adding useless files to your repo as #Dmitri Sandler said and you will be able to push everything easily
Generally you should think about files not folders. Try to use wildcard in the path:
git add <folder>/*
It is a good idea to use git status to see what files were staged for commit prior to committing them.
I am working on the same project with another person, and we sync our work using Git. Whenever we do a git push / git pull the paths to our external libraries are updated with paths that are valid only for the other person's machine. The paths are defined here:
I have nothing in my .gitignore file. How can I fix this issue?
You have committed some files to your Git repo that are designed to be user-specific, and should not have been committed.
Add a .gitignore file containing at least the following:
.metadata
.classpath
Or better, import one from e.g. gitignore.io.
To remove the files you have already committed to the repo:
git rm --cached -r .metadata
git rm --cached MyProject/.classpath
and commit the changes (including your .gitignore).
The git rm commands will remove the files from the repo, but not from your working directory, so Eclipse can still find them. However, the files will be deleted from the working directory of anyone else who pulls this commit. To work around this, after the other devs have pulled your changes, you can have them do e.g.:
git checkout HEAD^ -- MyProject/.classpath
git checkout HEAD^ -- .metadata
# Unstage the files, if necessary.
git reset HEAD -- MyProject/.classpath
git reset HEAD -- .metadata
After all of this, you should be able to modify those paths per-user, and the changes will not be tracked by Git.
Group the Selenium jars into a User Library that you can reference from the .classpath file, but define differently on each machine. It adds a layer of indirection that you seem to need. http://help.eclipse.org/neon/topic/org.eclipse.jdt.doc.user/reference/preferences/java/buildpath/ref-preferences-user-libraries.htm?cp=1_4_2_0_1_1
It may be something simple, but I cannot make git ignore this. I have put different combinations of things into the .gitignore file in the directory at the root of my repository.
But I still see:
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: .gitignore
modified: MyProject/build/.version
no changes added to commit (use "git add" and/or "git commit -a")
$
I have "build" in my .gitignore file. I have tried "MyProject/build/.version", "build/.version", ".version" and various combinations thereof. But perhaps not the right combination.
If you've only just added build to your .gitignore, then the files which were tracked before will still be tracked. .gitignore only prevents git from tracking new, untracked files which match the pattern given. To remove the file from git's history, without removing the file locally, you can run
git rm -r --cached build
to remove everything in the build directory, or
git rm --cached MyProject/build/.version
(or whatever the path is) to just remove the one file.
Try entering the following in your .gitignore:
/build
Another thing to try is
build/