3 ms·
iirc ours is always the commit the merge is starting from. the issue is that with a merge your current commit is the merging commit while with a rebase it is re
by afiori 7mo ago
iirc ours is always the commit the merge is starting from. the issue is that with a merge your current commit is the merging commit while with a rebase it is reversed.
I suspect that this could be because the rebase command is implemented as a serie of merges/cherry-picks from the target branch.
- devnotes77 7mo ago[dead]
- Sharlin 7mo agogit checkout mybranch git rebase main Now git takes main and starts cloning (cherry-picking, as you said) commits from mybranch on top of it. From git's viewpoint it's working on top of main, so if a conflict occurs, main is "ours" and mybranch is "theirs". But from your viewpoint you're still on mybranch, and indeed are left on mybranch when the rebase is complete. (It's a different mybranch, of course; once the rebase is completed, git moves mybranch to point to the new (detached) HEAD.) Which makes "ours" and "theirs" exactly the opposite of what the user expects.
- XorNot 7mo agoMan do I hate this behavior because it would be really some by just using the branch names rather then "ours" and "theirs"
- Sharlin 7mo agoAgreed. Even when the branch is the same, it would always be distinguishable by <remote-name>/<branch-name> vs. just <branch-name>.
- orthoxerox 7mo agoI had to make an alias for rebasing, because I kept doing the opposite: git checkout master #check out the branch to apply commits to git rebase mybranch #Apply all commits from mybranch Now I just write rebase-current-branch and it does what I want: fetches origin/master and rebases my working branch on top of it. But "ours"/"theirs" still keeps tripping me up.
- cerved 7mo agoTip, you may want to use origin/HEAD over origin/master
- orthoxerox 7mo agoIs it the naming-independent identifier of the tip of the trunk?
- cerved 6mo agonot strictly speaking, but in practice it's the tip of the remote default branch
- skydhash 7mo agoYou can use the --onto flag for git rebase git rebase --onto origin/master It will checkout origin/master and replay the current branch on top. P.S. I had to check the man page as I use Magit. In the latter I tap r, then u. In magit my upstream is usually the main trunk. You can also tap e instead of u to choose the base branch.