Skip to content

Instantly share code, notes, and snippets.

@WesleyDRobinson
Last active August 15, 2018 23:15
Show Gist options
  • Save WesleyDRobinson/5ae42485a3ffccbc33d6708552d283e5 to your computer and use it in GitHub Desktop.
Save WesleyDRobinson/5ae42485a3ffccbc33d6708552d283e5 to your computer and use it in GitHub Desktop.
Navigating Git rebase with squash & fixup

It all started with a $ git init

Make a branch:

git checkout -b branch

Do stuff in multiple commits

Rebase before pushing to Github

for sanity, clarity, and posterity

git rebase -i master

By default, each commit in the list will be "pick"'ed

Alter each commit according to the following options:

If you "Squash" (ˈskwëtch), an editor will open:

Do your thing! Really, go wild!

If you mess up the rebase, you can always git rebase --abort and begin again

Now observe your clean git tree!

git log --graph --pretty=format:'\''%Cred%h%Creset %C(cyan)%an%Creset -%C(blue)%d%Creset %s %Cgreen(%cr)%Creset'\'' --abbrev-commit

To dig into commit messages further:

git log 311b73b

Make your PR!

Bonus tip for the reader:

git reset HEAD~ will unstage all files from a commit while keeping all the code changes.

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