Git: Quickly Rebase Onto Previous Branch
Today I learned that you can use a dash -
with git rebase
to quickly rebase your current branch onto the previous branch you were on. This is a handy shortcut if you’re hopping between branches and want to rebase without typing the full branch name.
For example, after switching between branches:
git checkout main
git pull --rebase
git checkout new-feature-branch
git rebase -
The -
here ^ refers to the last branch you were on (main in this case), so this command is equivalent to git rebase main.
It's funny that I used this all the time with git checkout
but it never occurred to me that I could use for other git commands.