git rebase失败:了解我的存储库的状态

时间:2014-02-26 16:12:00

标签: git

my_branch上重新定位other_branch时,即:

git rebase other_branch

如果有冲突,我会得到标记

<<<<<<< HEAD
stuff_1
=====
stuff_2
>>>>>>> Some commit message 

Q1 第一个问题:stuff_1来自my_branch还是来自other_branch

我还注意到,当发生这种情况时,我的HEAD现在指向一些未命名的提交,在我的情况下65c47727a2500691233cfed2a2cfe7686b7fb92d(这是cat .git/HEAD的输出)

我也得到:

> git status
rebase in progress; onto e41e19d
You are currently rebasing branch 'my_branch" on 'e41e19d'
...
Unmerged paths:
both added: some_file.sh

Q2 当我修复rebase时,为什么我的HEAD指向某个随机提交?

第3季度 Unmerged pathsboth added在此背景下的含义是什么?

1 个答案:

答案 0 :(得分:4)

在变基过程开始时,HEAD设置为other_branchThat is documented。然后,逐个重新应用other_branch..my_branch的所有提交。该迭代过程可能在某些时候失败,然后您必须解决合并冲突,并在解决冲突后执行git rebase --continue

回答Q2:在解决冲突时,您的HEAD指向与上次成功应用的other_branch..my_branch提交相对应的提交。你可以使用git show进行识别,但当然它的哈希是不同的,因为它的父母是不同的。

回答Q1: stuff_1来自HEAD。鉴于我在Q2的答案中所说的,这意味着它来自other_branch的修改版本,其中my_branch的提交可能已经应用。

回答Q3: 未合并路径表示仍有未解决的冲突。似乎my_branchother_branch都添加了新文件some_file.sh。请参阅问题&#34; Resolving a 'both added' merge conflict in git?&#34;如何解决这一冲突。解决冲突后(在此处修复some_file.sh),一旦修复完毕,就会执行git add some_file.shgit rebase --continuegit-rebase将提交当前更改,并继续进行基础设置。

相关问题