git-subtree pull complications

梦想与她 提交于 2019-11-28 21:21:26

I had the same problem, and in my case it seems to be due to the initial subtree commit being merge-squashed into the master branch.

Looking through the subtree source I found this: https://github.com/git/git/blob/master/contrib/subtree/git-subtree.sh#L224

It looks like subtree greps your git log for git-subtree-dir: foo but doesn't find a suitable commit. Try git log --grep="git-subtree-dir: foo/*\$", and if there's something weird with that commit, such as it being a merge commit, that could be the issue.

Just pulling without squashing worked for me, apart from the annoying merge conflicts. I did that in a temporary branch which I then git merge --squashed into another branch to avoid a messier history. It could've been rebased instead too of course.

I've been experiencing the same error Can't squash-merge: 'foo' was never added. with sourcetree 1.7.0 whenever I do a pull on a subtree. However, I believe my case is different because I'm using subdirectories.

Sourcetree does something as follows:
git -c diff.mnemonicprefix=false -c core.quotepath=false subtree pull -P dir1\subdir1 --squash remote-repo master

And obviously, if we were to try it again in Git Bash (Git version 2.6.1.windows.1), it would be:
git subtree pull -P "dir1\subdir1" --squash remote-repo master

However that failed. The following also failed although the command syntax is fine:
git subtree pull -P dir1/subdir1 --squash remote-repo master

The solution I found to make it work is to use Git Bash with the following command:
git subtree pull -P "dir1/subdir" --squash remote-repo master

I guess that there is still some work to be done for Git's command-line processing engine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!