Skip to content

Instantly share code, notes, and snippets.

@abstractmachines
Last active October 22, 2020 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abstractmachines/6f043e821835e7f16bb0e5220b68a53c to your computer and use it in GitHub Desktop.
Save abstractmachines/6f043e821835e7f16bb0e5220b68a53c to your computer and use it in GitHub Desktop.
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