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? before git add --all . or git commit -m "comments" or git push origin master? Also before or after committing (or pushing) my gitignore?
  • 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 vs android.gitignore. If I simply do .gitignore the file will be hidden. Does github care which one I do?
Was it helpful?

Solution

  1. 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.

  2. git rm --cached filename for whichever file you want to ignore.

  3. yes, it needs to be .gitignore

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
scroll top