I cannot get git to unignore a subdirectory, even after excluding it in gitignore

In my .gitignore file, I was ignoring a directory like this:


  • Installing Git on a Debian Lenny server
  • Git ignoring my .gitignore on a Rails project
  • Git fatal ambiguous argument 'HEAD' both revision and file name use — to separate paths from revision like git --
  • ssh config not working. Permission denied (publickey)
  • setting tabwidth to 4 in git show / git diff
  • How to revert to older version in git
  • Then I realized I want to track var/package and all its contents. So, I’ve added that exclusion to gitignore. I’ve tried many combinations, but have settled on the following for what seems to be logical, especially from other discussions here.


    But whenever new files are written to var/package, they are not detected. They are added if I –force them specifically, but not through usual procedures such as git add .

    Is there a command I need to be issuing to reset .gitignore to now finally pick up the new gitignore instructions? Am I missing something?

  • Handling outdated dependencies in Gerrit
  • GIT Packfile claims to have more objects, inaccessable
  • Switch from SVN to GIT for C# developments?
  • Why do I have to “git push --set-upstream origin <branch>”?
  • Diff current file version and previous one remote repository
  • Do I ever need to run git gc on a bare repo?
  • One Solution collect form web for “I cannot get git to unignore a subdirectory, even after excluding it in gitignore”

    Remove anything about var from .gitignore. Create a var/.gitignore with the contents:


    You will obviously need to git add -f var/.gitignore but after that all should be well.

    another option is, in your top level .gitignore, say:


    If either do not work, please type find . -name .gitignore | xargs egrep . and cat .git/info/exclude and let us know what it returns.

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