6

I have a directory doc that was in .gitignore. I decided git should track changes in it. But after removing doc entry from .gitignore, git didn't automatically start tracking the directory.

How can I force git to watch for changes in that directory?

My second concern is, while looking for an answer to above question I found this thread: Ignore files that have already been committed to a Git repository and performed these operations:

git rm -r --cached .
git add .
git commit -m ".gitignore is now working"

I understand that it was wrong move; the above thread discussed totally opposite situation. Did I ruined something rather badly?

All this is done on a private, semi-serious project.

Thank you very much!

Community
  • 1
  • 1
B.I.
  • 706
  • 3
  • 9
  • 19
  • I think this is similar: http://stackoverflow.com/questions/11126292/git-trouble-un-ignoring-previously-ignored-files – B.I. Oct 18 '13 at 08:35

5 Answers5

5

Git doesn't track directories at all, rather it tracks (file) content. It may be that you have other conditions in the .gitignore, particulalrly a !dir which then, as an optimisation in recent versions, no longer reads further gitignore files in any lower directories.

The gitignore capability is a powerful tool, but has traps for the unwary.

Philip Oakley
  • 13,333
  • 9
  • 48
  • 71
1

I removed doc/ folder from project_name/.gitignore file. But there is global config file in user home directory, ~/.gitignore.

And I forgot that I entered doc/ in that file too. So, after erasing doc/ from .gitignore in home directory, everything went smooth.

alex
  • 479,566
  • 201
  • 878
  • 984
B.I.
  • 706
  • 3
  • 9
  • 19
  • 1
    You can check what untracked files are hitting your exclude patterns with [`git ls-files -io --exclude-standard`](https://www.kernel.org/pub/software/scm/git/docs/git-ls-files.html), for tracked files it'd be `-ic` not `-io`. – jthill Oct 19 '13 at 17:25
0

Similar problem, deleted a folder from the project .gitignore file and git was still ignoring it. The global file did not contain the folder either, but when I looked in .gitconfig I saw this line:

excludesfile = c://www/.gitignore_global

This was the file that still had my folder listed, removing the file solved the problem.

KAS
  • 53
  • 1
  • 5
0

If you have another .gitignore file in any subdirectory, Git will also consider it.

TuaimiAA
  • 973
  • 6
  • 15
0

I had similar issue. In my case I had projects folder was ignored initially. I removed projects/ entry which was there in .gitignore file. removing that entry didn't help at all.

My solution

  1. run git status --ignored will give you all ignored files/paths.

  2. run git add -f <file> where <file> could be a file name OR a path that you want to track back. So I had to run git add -f projects/ and

immediately everything under projects folder appeared as changed files.

micronyks
  • 54,797
  • 15
  • 112
  • 146