Force git to update .gitignore
I have a
.gitignore file, and it’s ignoring some files. I have updated the
.gitignore file (removed some filenames and added some filenames). This is not reflected in
git status. How can I force git to update these changes, so that track files which are not tracked before and vice versa.
I have tried this question, still all of my files are not tracked (according to my updated
.gitignore). (In simple, how can I force git to retract files once
.gitignore is updated or deleted).
3 Solutions collect form web for “Force git to update .gitignore”
If you want to add all files, delete all filenames from
.gitignore file, not the
.gitignore file and
commit it, then try
git config --global core.excludesfile ~/.gitignore_global
Some files are ignored by the git depending on the OS (like .dll in windows). For more information.
git add . git status git commit -m "your message"
You can try a simple hack, it may or may not work. Delete all filenames from
.gitignore file and add this line
You will have to clear the
git rm -r --cached .
git add .
git commit -m "Suitable Message"
Assuming here that your current working directory is empty.
You can check what files git is currently tracking by using
git ls-files. If you have a lot of files, you can use
git ls-files | grep hello.txt to find if git is tracking that specific file.
If it is tracking it, then use
git rm hello.txt to untrack it (as Tim mentioned in his comment). Perhaps commit that untracked state first and then add it in to your
.gitignore on your next commit. I have seen some funky behavior in the past when trying to ignore and remove in the same commit.