After git commit, commit revoked

After writing the code, so we generally

the Add git. // add all files 

git the commit -m " This function is completed ."

 

 

After executing commit, would like to withdraw commit, how do?

 

You can execute the following command to revoke commit:

git reset --soft HEAD^

 

 

This success was withdrawn your commit

Note that only the withdrawal commit operation, you write code remains.

 

 

Say my personal understanding:
the HEAD ^ means that the previous version can also be written HEAD ~ 1

If you were twice commit, would like to have withdrawn, you can use HEAD ~ 2

 

As these parameters:
--mixed 
means: do not delete a workspace change the code, the revocation of commit, and undo git add operation.
This is the default parameter, git reset --mixed HEAD ^ and git reset HEAD ^ effect is the same.


--soft  
not delete a workspace change the code, revocation commit, not revoked git add. 

--hard
delete a workspace change the code, revocation commit, undo git add. 

Note that after the completion of this operation, it is restored to the last commit state.

 

 

By the way, if the commit comment was wrong, just want to change about the comment, you need only:

git commit --amend

 

At this time will enter a default vim editor, save changes after a comment like finish.

Reproduced in: https: //www.cnblogs.com/ryanzheng/p/11120883.html

Guess you like

Origin blog.csdn.net/weixin_34395205/article/details/94605142
Recommended