我不确定我做了什么,因为我不太了解git并且刚开始输入命令。我的目的是删除自上次提交以来我所做的更改,但看起来我已经删除了自我第一次提交以来在存储库中的所有更改。当我运行git log时,只显示2/23的提交。是否有命令将最新版本退出?
26ceb46 HEAD@{0}: reset: moving to 26ceb4673a42710adb16840cc2f96e2073869eb5
e9c0494 HEAD@{1}: commit: After root fiasco, about to change illustration, novel, and edition models
e6ca6e6 HEAD@{2}: commit: Before adding edition as a table
17b2d98 HEAD@{3}: commit: Added search grid view, pagination on search grid view and index view.
d582f81 HEAD@{4}: commit: Before fixing tag display page
117cf37 HEAD@{5}: commit: Commit before adding tagging_id to illustration table
a543a4b HEAD@{6}: commit: Search bar and search results page working
d372d6e HEAD@{7}: commit: Fixed formatting, added search bar
0188759 HEAD@{8}: commit: Style changes, implemented basic grid views, Removed extra models/controlle
003cc92 HEAD@{9}: commit: Swapped to mysql
8cfd94e HEAD@{10}: checkout: moving from master to mysql-transition
8cfd94e HEAD@{11}: commit: Before Novel
2cc012b HEAD@{12}: commit: Archive Scaffold
26ceb46 HEAD@{13}: commit (initial): Archive Scaffold
答案 0 :(得分:1)
输入git reflog
。您将列出所有更改的历史记录。您可以在更改之前安全地结帐以提交。
答案 1 :(得分:1)
现在您已确定要还原的提交,可以发出命令
git checkout e9c0494
答案 2 :(得分:0)
这应该列出您的reflog中仍然存在的所有无法访问的提交。
git fsck --unreachable --no-reflogs 2>/dev/null | grep 'unreachable commit' | awk '{print $3;}
然后你可以运行git show SHA1
来显示提交消息和差异。
请注意,无法访问的git提交会在reflog中保留30天。
示例:强>
$ git fsck --unreachable --no-reflogs 2>/dev/null | grep 'unreachable commit' | awk '{print $3;}
bb308ef25fd7c3e0e5643bfec6a64c990724f25c
f0067516d9ce241a7fad1d03f4bd418172d1c7c4
f226f1200efdbe3687760e717d6670715e288439
$ git show bb308ef25fd7c3e0e5643bfec6a64c990724f25c
commit bb308ef25fd7c3e0e5643bfec6a64c990724f25c
Author: Ash <tuxdude@Suse1520>
Date: Sat Mar 23 13:36:36 2013 -0700
Removed Something.
diff --git a/file1 b/file1
index b9330fb..e69de29 100644
--- a/file1
+++ b/file1
@@ -1 +0,0 @@
-SOMETHING
如果您想查看工作树的外观,您还可以使用git checkout SHA1
直接签出该提交