git-subtree拉并发症 [英] git-subtree pull complications

查看:688
本文介绍了git-subtree拉并发症的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们一直在努力让 git-subtree 开发一个项目(使用git 1.7版本.9.4),并且遇到了一些复杂情况。几个月前,其他人以前使用这个命令添加了子树:

  git subtree add --prefix = foo git@example.com :foo.git master 

现在对 foo ,我们希望在这些更改中进行合并,理想情况下将它们压缩。没有任何文件在导入后未被修改。



我尝试了三件事来尝试合并变更。



第一:

  git subtree pull --squash -P foo git@example.com:foo.git master 

抛出异常:无法压缩合并:'foo'永远不会被添加。

第二:

  git subtree pull -P foo git @例子.com:foo.git master 

这种方式可行(但有)所有提交并与已修改的文件发生冲突。



最后,我试过这个:

  git pull --squash -s subtree git@example.com:foo.git master 

这给了我想要的结果,输出自动合并进行得很顺利;在提交之前停止和所有显示为已修改的文件(使用正确的内容)。



理想情况下,我想继续使用第一个 git-subtree 版本并获得接近最后一个版本的输出。如果我们必须始终使用最后一个版本,那么我们会这么做,但我有点困惑,为什么最后一个不会在中间产生合并冲突。



任何帮助表示赞赏。

解决方案

我有同样的问题,在我看来,这似乎是由于最初的子树提交被合并压缩到master分支中。

仔细查看子树源,我发现这个: https://github.com/git/git/blob/master/contrib/subtree/git-subtree.sh#L224



它看起来像子树会让你的git日志满足 git-subtree-dir:foo 但不会找到一个合适的提交。试试 git log --grep =git-subtree-dir:foo / * \ $,如果这个提交有些奇怪的东西,比如它是一个合并提交,这可能是问题。



除了恼人的合并冲突之外,只要不压缩就可以为我工作。我在一个临时分支中执行了这个操作,然后我将 git merge --squash 编辑到另一个分支中,以避免混乱的历史记录。当然,它可能已经被重新设计。


We have been trying to get git-subtree working on a project (with git version 1.7.9.4) and have run into a bit of a complication. Someone else previous added the subtree with this command some months ago:

git subtree add --prefix=foo git@example.com:foo.git master

Now there have been substantive changes to foo and we'd like to merge in those changes, ideally squashing them in. None of the files have been modified since they were imported.

I've tried three things to try and merge in the changes.

First:

git subtree pull --squash -P foo git@example.com:foo.git master

Which throws the exception: Can't squash-merge: 'foo' was never added.

Second:

git subtree pull -P foo git@example.com:foo.git master

This works (sort of), but has the issue of pulling in all of the commits and has conflicts with the files that have been modified.

Finally, I tried this:

git pull --squash -s subtree git@example.com:foo.git  master

This gives me the desired result, with the output Automatic merge went well; stopped before committing as requested and all of the files showing up as modified (with the correct content).

Ideally I'd like to continue using first git-subtree version and get an output close to the last version. If we have to use the last version consistently going forward, we will, but I am a little confused as to why the last one doesn't produce merge conflicts while the middle one does.

Any help is appreciated.

解决方案

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.

这篇关于git-subtree拉并发症的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆