Git Worktree for a cheeky rebase

Let’s say you are at the end of a sprint and you want to rebase your Release branch on to staging, but you don’t want to switch branches in the project directory, because you have uncommitted changes or you are running tests, or anything that changing directory might disrupt.

git worktree add ../release-temp
# Open a new terminal, e.g. in TMUX
cd ../release-temp
git checkout release-branch
git rebase staging
exit
# close the terminal, and back in the original project directory
git worktree remove ../release-temp


all tags