I\'m looking to create a .gitignore
file so certain files are do not get checked in to the repository. Does anyone have a guide on how and where to place this f
You have to add .gitignore
to the index before Git sees it. I.e., git add .gitignore
.
Placement of .gitignore depends if the files need to be ignored for just one repo or for all your repos. For one repo, place it in the root of your repo.
When you create a .gitignore file in an existing repo, or add files that were already in the repo, you have to make sure to remove the to-be-ignored files from the repo.
If you have a test.dll in the root, you have to do
git rm --cached test.dll
Now if you have a lot of files, like you said you can opt for the following option, remove everything from the cache, add it all back (the files in .gitignore will not be added) and commit everything again.
git rm -r --cached .
git add .
git commit -m "Start using .gitignore"
From the link @thescientist has posted:
Git lets you ignore those files by assuming they are unchanged. This is done by running the
git update-index --assume-unchanged path/to/file.txt
command. Once marking a file as such, git will completely ignore any changes on that file; they will not show up when running git status or git diff, nor will they ever be committed.
The projects that I have worked on, I have the .gitignore file in the root directory of the project, where the .git directory would be. Make sure the file is committed.
Note, that if you have already committed the files you are trying to ignore (i.e. Git is tracking them) then they can't be ignored. You would have to untrack them first.
https://help.github.com/articles/ignoring-files