I make an arbitrary change to a file within my git working directory.
git status
does not recognized that the file has changed.
git add /path/to/file
has no effect.
git add -f /path/to/file
has no effect.
git status /path/to/file
shows the file as in the 'changes to be committed' bucket.
I removed my .gitignore file, just to be sure. No change to any of the above behaviors.
I have done git reset --hard
, re-made my change. No change to any of the above behaviors.
What could be going on here?
if your file is in the 'Changes to be committed' bucket then git already recognized the change and is going to commit it! Its in the index already. Otherwise it would be in the 'Changed but not updated' bucket.
:)
Hope this helps/
Also make sure that you have not manually updated the index to assume that the changed file(s) are unchanged like so:
As dumb as it sounds I did that, then a few days later made changes to the file and could not figure out why git was not tracking it. I tried all of the above suggestions, and kept pulling my hair out b/c the changed file was not listed in any
.gitignore
orexclude
files.If you've told git to assume the file is unchanged, you will have to:
or just re-clone the repo like I ended up doing before I remembered what I had done...
There are two general reasons why Git will ignore a file:
gitignore
andsubmodules
.To be more specific, the following conditions will cause Git to ignore a file when '
git add
' is invoked:$GIT_DIR/exclude
..gitignore
file inside the repo..gitignore
file (specified by 'git config --global core.excludesfile
').More info can be found in another SO question:
Unable to track files within Git submodules
Check each parent directory from the file in question to the project root for .gitignore files.
Some projects use several .gitignore files, each in its own directory, instead of a single .gitignore in the root.
You check your global git ignore file?
If either of those return a file as their value, look in that file.
Check using
if the file is truly not excluded (there are other exclude files than only .gitignore).