delete former commit github but keep current commit code example Example 1: undo last commit but keep changes git reset @~ Example 2: git revert commit but keep changes git reset HEAD^