Skip to content

Instantly share code, notes, and snippets.

@Martskin
Last active November 1, 2021 21:38
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 Martskin/e1eb37def5df8ca40a79f8efa427f18c to your computer and use it in GitHub Desktop.
Save Martskin/e1eb37def5df8ca40a79f8efa427f18c to your computer and use it in GitHub Desktop.

Rebase cheatsheat

Git rebase

  • git checkout main
  • git fetch
  • git pull origin main
  • git checkout [branch name]
  • git rebase main
  • git push --force

Git rebase and squash commits

  • git checkout main
  • git fetch
  • git pull origin main
  • git checkout [branch name]
  • git rebase main
  • git log --decorate
  • Copy the hash of the commit where main head is listed. commit f8a93d554620964f0c2b0bf88c0bc7ccb305901a (origin/main, origin/HEAD, main)
  • git reset --soft [hash]
  • git commit -m ""
  • git push --force

Use --fixup

https://fle.github.io/git-tip-keep-your-branch-clean-with-fixup-and-autosquash.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment