This article is a mirror article of machine translation, please click here to jump to the original article.

View: 11614|Reply: 1

git undo commit

[Copy link]
Posted on 4/28/2018 4:37:25 PM | | |
If you accidentally commit a file that does not need commit, you can undo it.

Use git log to check the commit log first

commit 422bc088a7d6c5429f1d0760d008d86c505f4abe  
Author: zhyq0826 <zhyq0826@gmail.com>  
Date:   Tue Sep 4 18:19:23 2012 +0800  
  
    Remove the limit on the number of recent searches  
  
commit 8da0fd772c3acabd6e21e85287bdcfcfe8e74c85  
Merge: 461ac36 0283074  
Author: zhyq0826 <zhyq0826@gmail.com>  
Date:   Tue Sep 4 18:16:09 2012 +0800  

Find the hash value of the commit that needs to be rolled back,

git reset --hard commit_id

Use the command above to roll back

The following is Douban's

Cang Yan's diary

Cause: No Xiaoxin submitted the file recording the company server IP, account number, and password to git

Methods:


Others:

    According to –soft –mixed –hard, the working tree and index and HEAD are reset:
    git reset –mixed: This is the default way, git reset without any parameters, that is, it falls back to a certain version, only the source code, the commit and index information are retained
    git reset –soft: Reverts to a certain version, only reverts the commit information, and does not revert to the index file level. If you still want to submit, just commit directly
    git reset –hard: Completely revert to a certain version, and the local source code will also change to the content of the previous version


    HEAD most recent commit
    HEAD^ Last time
    <commit_id> The SHA1 value for each commit. can be seen in the git log or in the commit tab on the page




Previous:MVC Model custom features
Next:Alibaba Cloud SMS mass marketing promotion tool download
Posted on 4/28/2018 5:40:22 PM |
https://git-scm.com/book/zh/v2
Git operation instructions
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com