继Nvie的git分支模型之后,为什么在将同一个'release'分支合并到两者之后,我们最终将每个1提前'开发'和'掌握'并且1个落后于另一个?如果将相同的'release'分支合并到每个分支中,那么不应该掌握并制定同意吗?
x 84a628d (origin/develop, develop) Merge branch 'release-v3.0.1' into develop
|\
| | x 2e4d60b (HEAD, v3.0.1, origin/master, master) Merge branch 'release-v3.0.1'
| | |\
| | |/
| |/|
| x | 716ce96 (release-v3.0.1) Version 3.0.1
|/ /
x | fe3b54d Some more more code
x | 3683892 Some more code
x | 8c0b835 'develop' branch code
|/
x d051b54 (v3.0) Baseline merge. Merge remote-tracking branch 'origin/master'
$ git log origin / master ^ origin / develop
commit 2e4d60b7d6760b4f6b2328ab06150b020b0d279f
Merge: d051b54 716ce96
Author: Todd
Date: Tue Mar 26 11:27:59 2013 -0400
Merge branch 'release-v3.0.1'
$ git log origin / develop ^ origin / master
commit 84a628d96653ed196faa6387c8b208badf23aa75
Merge: fe3b54d 716ce96
Author: Todd
Date: Tue Mar 26 11:31:53 2013 -0400
Merge branch 'release-v3.0.1' into develop
我错过了什么?
答案 0 :(得分:2)
git log origin/master ^origin/develop
此命令显示从origin/master
但不能从origin/develop
git log origin/develop ^origin/master
此命令显示从origin/develop
但不能从origin/master
上述两个命令的输出似乎与您显示的图形一致。
如果您想要找出2个分支内容的差异,您应该使用git diff
命令。
git diff origin/master..origin/develop
如果您只想要不同的文件列表,可以使用--name-status
选项:
git diff --name-status origin/master..origin/develop
在git中,提交的SHA1是根据父提交的SHA1,提交消息,时间戳和许多其他此类信息计算的。虽然您已将同一release-v3.0.1
分支合并到master
和develop
中,但您已在2个不同的时刻将其作为2个独立合并进行了合并。这显然不会为两者提供相同的提交SHA1。
您应该做的事情是以下之一:
选项1:
git checkout master:
git merge release-v3.0.1
git checkout develop:
git merge master
git checkout master
# This would be a fast-forward merge
git merge develop
选项2:
git checkout develop:
git merge release-v3.0.1
git checkout master:
git merge develop
git checkout develop
# This would be a fast-forward merge)
git merge master
这样,您最终会将master
和develop
分支指向同一个提交。
通过将master
合并到develop
或其他方式,并在另一个分支上进行快进合并,您甚至可以达到相同的状态。
git checkout master
git merge develop
git checkout develop
# This would be a fast-forward merge
git merge master