git rollback a commit but keep future changes code example Example 1: undo last commit but keep changes git reset @~ Example 2: git revert commit but keep changes git reset HEAD^