Git – Untrack files already added to git repository based on .gitignore

It happened that an IDE specific file or folder is tracked and push to remote repository without intention.

1. To remove an IDE specific track file or directory. First change directory to the path where the file or directory is located.

Then run the following command:
git rm --cached FILENAME

or

git rm -r --cached FOLDERNAME/

2. Add the FOLDERNAME/ or FILENAME within .gitignore.

3. Stage all files. git add .

4. Commit git commit -m "Remove IDE specific files".

5. Then do a git push to if you want to reflect the changes in remote repository.

Author: Wu Chia Chong

My main areas of interest are software architectures and software design methods, patterns, and new trends in software development.