Skip to content

Instantly share code, notes, and snippets.

@cssence
Created March 4, 2026 09:30
Show Gist options
  • Select an option

  • Save cssence/b5070a735a52704472bc02d42371b8cd to your computer and use it in GitHub Desktop.

Select an option

Save cssence/b5070a735a52704472bc02d42371b8cd to your computer and use it in GitHub Desktop.
Rebase feature branch after latest commit on target branch has been modified
# interactively rebase last <n> commits (defaults to 2):
# pick needed ones and drop those that got modified on target branch
git rebase -i HEAD~${1-"2"}
# now reintegrate target branch (defaults to main)
git rebase ${2-"main"}
echo "Learn more at https://cssence.com/2026/rebase-feature-branch/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment