1

When rebasing my_branch on other_branch, i.e.:

git rebase other_branch

if there is a conflict, I get the markers

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

Q1 First question: Is stuff_1 from my_branch or from other_branch ?

I also notice that, when this happens, my HEAD now points to some unnamed commit, in my case 65c47727a2500691233cfed2a2cfe7686b7fb92d (which is the output of cat .git/HEAD)

I also get:

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

Q2 While I fix the rebase, why does my HEAD point to some random commit?

Q3 What does Unmerged paths and both added mean in this context??

Amelio Vazquez-Reina
  • 91,494
  • 132
  • 359
  • 564

1 Answers1

4

At the beginning of the rebasing process, HEAD is set to other_branch. That is documented. Then, all commits of other_branch..my_branch are reapplied one by one. That iterative process can fail at some point, and then you have to resolve the merge conflict, and do git rebase --continue once you have resolved the conflict.

Answer to Q2: While you are resolving the conflict, your HEAD points to a commit that corresponds to the last commit of other_branch..my_branch that was successfully applied. You can recognize using git show, but of course its hash is different, because its parents are different.

Answer to Q1: stuff_1 is from HEAD. Given why I said in the answer to Q2, it means that it is from the modified version of other_branch where commits from my_branch may have already been applied.

Answer to Q3: Unmerged paths means that there are still unresolved conflicts. It seems that both my_branch and other_branch have added a new file some_file.sh. See the question "Resolving a 'both added' merge conflict in git?" for ways to resolve that conflict. Once you have resolved the conflict (fixing up some_file.sh here), you do git add some_file.sh, and git rebase --continue once you have fixed them all. git-rebase will commit the current change, and go on with the rebasing process.

Community
  • 1
  • 1
lrineau
  • 6,036
  • 3
  • 34
  • 47
  • 2
    "Unmerged paths" means that there are still unresolved conflicts. Once you have resolved the conflict (fixing up `some_file.sh` here), you do `git add some_file.sh` and `git rebase --continue` once you have fixed them all. – vonbrand Feb 26 '14 at 16:31
  • Thanks @lrineau. Conceptually speaking, why is adding (staging) the file after resolving the conflicts enough? Why don't I need to commit the file as well? – Amelio Vazquez-Reina Feb 26 '14 at 17:47
  • @user815423426: the commit is done by `git rebase --continue`. – lrineau Feb 26 '14 at 17:58