Skip to content

Instantly share code, notes, and snippets.

@Martskin
Last active November 1, 2021 21:38

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