我如何重置为我之前的提交?

时间:2015-08-11 00:32:21

标签: git

我已经非智能地使用了多个resets,我现在在我的git存储库中到处都是。以下是reflog的输出,我的问题是如何进入此提交modify GBSX_script for PstI/MspI enzyme

a4c0b87 HEAD@{0}: commit: add few changes
a465ae2 HEAD@{1}: reset: moving to HEAD@{8}
31a3dd2 HEAD@{2}: reset: moving to HEAD@{6}
7b4d404 HEAD@{3}: reset: moving to HEAD@{2}
a465ae2 HEAD@{4}: reset: moving to HEAD@{3}
498d4db HEAD@{5}: reset: moving to HEAD@{1}
7b4d404 HEAD@{6}: reset: moving to HEAD^
498d4db HEAD@{7}: reset: moving to HEAD^
a465ae2 HEAD@{8}: reset: moving to HEAD^
31a3dd2 HEAD@{9}: commit: modify GBSX_script for PstI/MspI enzyme
a465ae2 HEAD@{10}: commit: modify GBSX_script for ApeKI enzyme
498d4db HEAD@{11}: commit: add chr txt file for Aspen genome
7b4d404 HEAD@{12}: reset: moving to HEAD^
04aa5f6 HEAD@{13}: reset: moving to HEAD^^
563b93a HEAD@{14}: reset: moving to HEAD^
bc782a6 HEAD@{15}: commit: mend
563b93a HEAD@{16}: commit: add chr txt file for Aspen genome
56884a1 HEAD@{17}: commit: modify GBSX script for ApeK1 for Aspen
04aa5f6 HEAD@{18}: commit: modify chr file to Aspen
7b4d404 HEAD@{19}: commit: modify the GBSX_script.sh script to correct for 2nd enzyme
317ae1e HEAD@{20}: commit: modify the GBSX_script.sh script
a69b9de HEAD@{21}: commit (amend): trying with PST/MSP in the GBSX test script
502c7cb HEAD@{22}: commit (amend): rying with PST/MSP in the GBSX test script
f7046bc HEAD@{23}: commit: add PST/MSP recog sequence
b9ee79a HEAD@{24}: commit: update gitignore after running RE digest script
5ea495a HEAD@{25}: commit: add GBSX test script
f1e4dbc HEAD@{26}: commit: modify gitignore for fa files
c827fc4 HEAD@{27}: commit (initial): add gitignore

2 个答案:

答案 0 :(得分:3)

git reset允许您指向任何提交,而不仅仅是HEADHEAD^,因此我们可以使用SHA(最左边的列)

git reset 31a3dd2

如果要销毁代码库中的所有当前更改(而不仅仅是当前指向git的提交),可以使用--hard选项。

git reset --hard 31a3dd2

答案 1 :(得分:0)

您可以选择使用Git GUI代替Git Bash。

打开 Git GUI ,然后打开您的存储库。

在菜单按钮中,点击"存储库" ,然后选择"显示所有分支机构'历史"(类似这样,我不能给你准确的名字,因为它在我的电脑上不是英文)。如果您没有使用远程分支机构,则只需选择"显示XXX分支机构的历史记录"(类似的内容)

点击后,会出现一个标题以&#34开头的新窗口; gitk:"将弹出,你可以看到你提交的所有提交。然后只需右键单击要重置的提交,然后单击"将XXX分支重置为此处"

这是我知道的重置代码版本最直观的方法。希望它可以帮助你:))