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

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?


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 ...

I got around this now. My problem seemed to me that the repository was brand new: I had never committed anything to it. Once I committed a file to the repo, I was able to move past this error.

However, using the command git subtree add C:\gitTest\repos\subA -d --prefix subA I got the new error:

fatal just how do you expect me to merge 0 trees?

After messing around for a minute, I figured out it requires that a specific revision be passed to it. So this command seems to have succeeded:

git subtree add C:\gitTest\repos\subA HEAD -d --prefix subA

And obviously you don't need the -d debug flag.

git reset --hard fixed it to me

From git reset --help

--hard Resets the index and working tree. Any changes to tracked files in the working tree since are discarded.

I just had this problem, when I:

  • added a subtree;
  • realized, I added it incorrectly (to a wrong directory);
  • removed it with rm;
  • tried to import it again (to the correct place).

Although puppet diff was -- correctly -- showing nothing, the git diff-index HEAD listed each of the files I just deleted as "deleted" -- even though I never commit-ed (much less push-ed) anything.

I believe, this is a bug in git (using 2.7.0 here)... Bug or not, the work-around is to switch to any other branch (with the usual git checkout ....) and then back to yours. Hope, this helps someone -- even if not the original asker.

If you are using Windows, try to use Git Bash instead of PowerShell or cmd.exe. This fixed the problem in my case.

Try to pull without --squash as it is described in this stackoverflow question.

Need Your Help

ASPxGridView Pager disappears

paging pager aspxgridview

I use the ASPxGridView with paging, pager settings is next: