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
|