git rm --cached filename is used to stop tracking a file without deleting it from your working tree. Example: You create a new file, start tracking with git add, and then commit. You want to ignore the file, so you add it to .gitignore git is still tracking the file when you make changes to it, this is when you git rm --cached git thinks the file is gone, but it's still there in your local directory.
git rm --cached filename for whichever file you want to ignore.
yes, it needs to be .gitignore
A few questions about adding gitignore after multiple commits
Question
I have created my gitignore
file and have added it to my local repo. I understand that I have to do git rm --cached
. So here are my questions.
- When in the process should I do
git rm --cached
? beforegit add --all .
orgit commit -m "comments"
orgit push origin master
? Also before or after committing (or pushing) mygitignore
? - Is
git rm --cached
the whole command? or must I always qualify it with, for example,git rm --cached /bin/*
? - my mac computer gave me a warning about naming my file
.gitignore
vsandroid.gitignore
. If I simply do.gitignore
the file will be hidden. Does github care which one I do?
Solution
OTHER TIPS
You should use git rm --cached before "git add" and you should list the files in .gitignore. The relationship of git rm to committing/pushing .gitignore is not relevant, but please do perform "git add" after you change .gitignore locally.
Github recognizes .gitignore and that is what you should use.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow