在这个例子中,git并不认为它需要重定位,但很明显。为什么这个git rebase认为没有什么可做的?
下面是一个简单的脚本在这之后运行,以创建一个小型测试git仓库
#!/bin/bash
rm -rf testgit
mkdir testgit
cd testgit
git init
echo -e "a\nb\nc" > file
git add file
git commit -am 'first'
git checkout -b lineA
echo -e "A\nb\nc" > file
git commit -am 'A'
git checkout -b lineB
echo -e "a\nB\nc" > file
git commit -am 'B'
git checkout -b lineC
echo -e "a\nb\nC" > file
git commit -am 'C'
,这里是file
看起来像每个分支
master | lineA | lineB | lineC
------------------------------
a A a a
b b B b
c c c C
现在,让我们所有的分支机构合并成高手,之后file
中的每个字母应该大写
$ git checkout master
$ git merge lineA
好的。
$ git checkout lineB
$ git rebase master
Current branch lineB is up to date.
什么?不,主人改变了。
$ git checkout master
$ cat file
A
b
c
$ git checkout lineB
$ cat file
a
B
c
在我看来,分支lineB需要重新绑定,以将合并lineA所做的更改合并到master中。
为什么不git认为这需要做?
此外,如果你这样做
$ git checkout master
$ git merge lineA
Already up-to-date.
$ git merge lineB
...
1 file changed, 2 insertions(+), 2 deletions(-)
$ cat file
a
B
c
$ git merge lineC
...
1 file changed, 2 insertions(+), 2 deletions(-)
$ cat file
a
b
C
这里的合并应该发生冲突,但Git是悄悄重挫他们。我不知道这是否相关,但似乎很奇怪。
我想也一样。使用git扩展来查看你的分支树形状。对于我来说,所有你创建的分支都有他们的主人,所以git以它的方式告诉你,不需要rebase。在这一点上,你只需要合并 –