Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Interactive Rebase on CLI

Interactive rebase on the CLI

This workflow is outside of the "git pull -r origin branchName" workflow we use for rebases without merge commmits. This workflow is just to squash commits on a local/unshared branch. Keep in mind that "rewriting history can make teammates sad, angry or worse" standard warnings about rebasing.

  1. Choose the commit hash which will "choose everything AFTER this commit to rebase."
  2. Remember you're rebasing a branch against itself, not src/destination rebasing like normal rebasing workflow.
  3. git rebase -i hash123-everything-after-this-commit
  4. That'll send you into a screen that's a list of commits. Use rename, squash etc. then :x to save/exit...
  5. That'll send you into the standard git commit screen. First you'll reword any you marked with reword or r, and save.
  6. Then you'll be sent back into the standard git commit screen for any commits you squashed. Pick one commit, squash all others you don't want.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment