3 ms·
My eyes were opened on git-rebase when I read https://matthew-brett.github.io/pydagogue/rebase_without_tears.html https://matthew-brett.github.io/pydagogue/reba
by malingo 7y ago
My eyes were opened on git-rebase when I read https://matthew-brett.github.io/pydagogue/rebase_without_tears.html https://matthew-brett.github.io/pydagogue/rebase_without_tea...
The full version of the command as
$ git rebase --onto new-base start end
takes the commit range (start,end] and re-commits them on top of the new-base commit. The commit range doesn't have to be a full branch and you don't even need to be on the branch to run the command this way. It's very intuitive and I nearly always use the full version now.
I've also gotten into the habit of "pinning" my branch before I rebase so that I have it in its original form. If the branch name is my-branch, then the command
$ git branch my-branch{-hold,}
which is a handy (bash-specific?) shortcut of
$ git branch my-branch-hold my-branch
leaves you on my-branch and creates a new branch label called my-branch-hold that points to the same place.
EDIT: clarification of pre-rebase branching
- gbacon 7y agoI’ll sometimes do the same for a rebase that looks like it will be hairy, and I like to call the bookmarks, for example, git branch my-branch-mulligan