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

  • How to remove unstaged changes in git?
  • Migrate from Git to Svn
  • bisect everything, from initial commit
  • Show commits made on branch originally (filter out merged commits)
  • Setting umask in Git / Gitolite
  • Merge pull request into different branch
  • Commit with specific date using JGit Eclipse
  • git remove oldest revisions of a file
  • Why do I get “unable to connect a socket” when I try to clone via a git URL?
  • How to add an Android Studio project to GitHub
  • Get a CVS log/history similar to the “git log” command?
  • git rebase after pull
  • 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 !*.*, then add and commit.

    You will have to clear the cache first.

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

    Git Baby is a git and github fan, let's start git clone.