Skip to content

Instantly share code, notes, and snippets.

@thadeu
Created July 19, 2018 15:55
Show Gist options
  • Save thadeu/8161d51260c4af1204124466f1c7c07d to your computer and use it in GitHub Desktop.
Save thadeu/8161d51260c4af1204124466f1c7c07d to your computer and use it in GitHub Desktop.
squash and join commits with git rebase

First Check the commits

git log --pretty=oneline --since=1.day

Second

Choose many commits would should be edits

git rebase -i HEAD~N_COMMITS

Third

Use commands

# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit

Finally

git push -f origin HEAD

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