git subtree pull says that the working tree has modifications, but git status says it doesn't. What gives?

Sam Deane picture Sam Deane · Sep 2, 2010 · Viewed 24.8k times · Source

If I do this in one of my repositories:

git subtree pull --prefix=frameworks/AquaticPrime --squash AquaticPrime

I get this:

Working tree has modifications.  Cannot add.

If I do this (in the same place, of course):

git status

I get this:

# On branch master
nothing to commit (working directory clean)

I'm not quite sure what's going on here. The git status command implies that I don't have modifications, so I'm assuming that the git subtree pull is referring to modifications in a different branch related to the subtree, but it's not entirely clear.

Can anyone provide enlightenment?

Answer

Koryonik picture Koryonik · Sep 4, 2013

I just had the same problem. From GIT source, error is thrown when command git diff-index HEAD returns result, even if git status says working tree is clean.

To avoid this error, in my case, I re-checkout the current branch of working tree , and everything seems OK : git checkout <branch>

It's a bit confused, but if someone can explain why ...