Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

subtree

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?

like image 907
Sam Deane Avatar asked Sep 02 '10 02:09

Sam Deane


People also ask

How does Git subtree work?

git subtree allows you to nest a repository as a subdirectory inside another. It's one of the various options for managing project dependencies in Git projects. You add a subtree to an existing repository where the subtree is a reference to another repository URL and branch/tag when you wish to utilize it.

How do you pull a subtree?

Adding a subtreeSpecify the prefix local directory into which you want to pull the subtree. Specify the remote repository URL [of the subtree being pulled in] Specify the remote branch [of the subtree being pulled in] Specify you want to squash all the remote repository's [the subtree's] logs.

How do you push a subtree?

subtree : push: allow specifying a local rev other than HEAD ' git push '(man) lets you specify a mapping between a local thing and a remot ref. So smash those together, and have git subtree push let you specify which local thing to run split on and push the result of that split to the remote ref.


2 Answers

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

like image 140
Koryonik Avatar answered Sep 22 '22 03:09

Koryonik


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.

like image 38
Anssi Avatar answered Sep 23 '22 03:09

Anssi