11

Commiting in git is like commiting in real life. It's hard to undo.

Comments
  • 9
    No it's not.

    git commit --amend
    git rebase -i master
    git reset --soft HEAD~

    If only life had any of these...
  • 2
    @shellbug why no git revert? If anything it's actually undoing a commit. Git amend just changes the the last commit message the code changes are still in the branch, right?
  • 2
    @StyxOfDynamite That works, too, but git revert creates a new commit to undo what you did and doesn't change your repo's history. It's your only option if your trying to change things you already pushed.

    I listed commands one can use to actually change history. The git rebase -i is my favourite: you can remove, reorder and join (squash) commits.
  • 2
    And I should add: these should never be done in the master branch.
Add Comment