Back up a remote branch

Create a local backup copy of a remote branch before doing risky operations like rebasing.

git checkout -b backup-2222 origin/feature/PROJ-2222

How it works

  • Creates a new local branch backup-2222
  • Points it to the same commit as origin/feature/PROJ-2222
  • The backup won’t be affected by changes to the original branch

Verify the backup

git log --oneline backup-2222 -5

Use cases

  • Before interactive rebasing
  • Before force-pushing changes
  • Before merging complex branches
  • When experimenting with git history

Now you can safely rebase feature/PROJ-2222 knowing you have backup-2222 to fall back to if things go wrong!