Thursday, July 21, 2016

GIT: Undo a commit before push

git commit -m "Something terribly misguided"              (1)
git reset HEAD~                                                        (2)
<< edit files as necessary >>                                      (3)
git add ...                                                                   (4)
git push                                                                      (5)

(1) This is what you normally do to commit your changes
(2) This will undo the commit (i.e. if you do git status, you'll see the list of uncommitted files)
(3) Make corrections/changes to working tree files
(4) git add whatever you want to include in your new commit.
(5) push changes to server




Source: http://stackoverflow.com/questions/927358/how-to-undo-last-commits

No comments:

Post a Comment