tags:

views:

190

answers:

6

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?

A: 

You check your global git ignore file?

git config --global --get-all core.excludesfile
git config --system --get-all core.excludesfile

If either of those return a file as their value, look in that file.

davetron5000
neither of those commands returned a value. To answer my own question, I managed to get them to commit by doing 'git commit /path/to/file', and could do a patch commit by doing 'git rebase -i HEAD~2' and editing the commit. Still no idea why they were being ignored in the first place.
joshwa
+1  A: 

Are you sure that your file is not excluded by some of the .gitignore files in parent directories?

hlovdal
A: 

After you did git add, did you do a commit so it's actually in the repo and can be compared to the (changed) working copy?

kajaco
+1  A: 

There are two general reasons why Git will ignore a file: gitignore and submodules.

To be more specific, the following conditions will cause Git to ignore a file when 'git add' is invoked:

  1. The file matches a pattern in $GIT_DIR/exclude.
  2. The file matches a pattern in a .gitignore file inside the repo.
  3. The file matches a pattern in a user-specific .gitignore file (specified by 'git config --global core.excludesfile').
  4. The file is part of a submodule.

More info can be found in another SO question:

http://stackoverflow.com/questions/1084969/unable-to-track-files-in-deep-directories-by-git

Tim Henigan
+2  A: 

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/

Vitaly Kushner
This is not true if this is the result of a `git status <filepath>` command. In this case `git status` is showing what would be committed if you supplied the given parameters to git commit. With an explicit path, any changes are added and committed in one go, it makes no differences if they were staged or not.
Charles Bailey
A: 

Check using

$ git ls-files --exclude-standard --ignore

if the file is truly not excluded (there are other exclude files than only .gitignore).

Jakub Narębski