Skip to content

Instantly share code, notes, and snippets.

@svofski
Last active April 19, 2018 12:27
Show Gist options
  • Save svofski/68e5fed2512d493d670dd146387dfe5b to your computer and use it in GitHub Desktop.
Save svofski/68e5fed2512d493d670dd146387dfe5b to your computer and use it in GitHub Desktop.

Squash remote commits

(https://stackoverflow.com/questions/5667884/how-to-squash-commits-in-git-after-they-have-been-pushed)

git rebase -i origin/master~4 master
git push origin +master

Undo commit --amend

https://stackoverflow.com/questions/1459150/how-to-undo-git-commit-amend-done-instead-of-git-commit

Move the current head so that it's pointing at the old commit Leave the index intact for redoing the commit. HEAD@{1} gives you "the commit that HEAD pointed at before it was moved to where it currently points at". Note that this is different from HEAD~1, which gives you "the commit that is the parent node of the commit that HEAD is currently pointing to."

git reset --soft HEAD@{1}

commit the current tree using the commit details of the previous HEAD commit. (Note that HEAD@{1} is pointing somewhere different from the previous command. It's now pointing at the erroneously amended commit.)

git commit -C HEAD@{1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment