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

Viewed 29625

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?

7 Answers

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

I had the exact same error. This was occurring on my feature branch. The fix:

  1. Pulled from feature branch remote to local
  2. Pulled from master remote to local
  3. Merged local master to feature branch, committed, and pushed to remote
  4. Ran the `git subtree pull --prefix MySubdirection https://my/repository/url remotebranch --squash

I have no clue why I had to get master and merge to my feature branch, but that solved the issues.

Related