How can I undo my last commit in Git? [duplicate]

2

I made the wrong file commit. I did not push the commit to the server.

How can I undo these commits?

    
asked by marco gomes 23.07.2017 в 18:21
source

2 answers

1

You can do it using the command git reset HEAD~ or git reset HEAD~1 that allows you to pass the changes of the last commit to the work area. HEAD~ means that it moves back one position with respect to the last commit ( HEAD ).

    
answered by 23.07.2017 в 19:01
0
git revert HEAD

Do not delete the commit, create a new one where the last commit is reversed.

    
answered by 23.07.2017 в 18:42