I have applied the following commands, but have little confusion in doing rebase - what is ours and theirs in the following commands
git checkout app/dashboard-sprint-5
git rebase app/demandware
I know the current branch is app/dashboard-sprint-5
and when i apply the rebase.
app/dashboard-sprint-5
will be applied on the top of app/demandware
.
What is ours
and theirs
in terms of branches.
I have checked the link but not satisfied
Briefly, when we are talking about rebase, ours
means the base branch.
So in your case ours
will be app/demandware
, since firstly git moves us there, and then applies changes from the app/dashboard-sprint-5
, which will be theirs
.
For example, here the note from documentation about rebase and ours
word:
Because git rebase replays each commit from the working branch on top of the <upstream> branch using the given strategy, using the ours strategy simply discards all patches from the <branch>, which makes little sense.
In order to easily remember the direction of ours and theirs, think of rebasing as cherry-picking each commit of the current branch onto the target branch.
Before rebasing:
A--B--C (master)
'--D--E (devel, HEAD)
Reset HEAD to master:
A--B--C (master, HEAD)
'--D--E (devel)
Cherry-pick D, E.
A--B--C (master)
| '-- D'--E' (HEAD)
'--D--E (devel)
HEAD becomes "ours" and the old devel branch "theirs".
^^^^ ^^^^^^
On success, repoint devel to E':
A--B--C (master)
'--D'--E' (devel, HEAD)
In a non-interactive rebase that goes through without conflicts, it looks like we jump straight from the old devel-branch history to the rebased devel-branch history. In this view the inversion of ours and theirs isn't apparent, leading to potential confusion, especially also during merge conflict resolution – it is simply a bit unexpected, that the branch we started from may suddenly be called "remote branch" by merge tools.
Though this question was already answered, I add this more visual explanation, since I found it difficult to remember the result without.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With