发布网友 发布时间:2022-04-24 02:13
共1个回答
热心网友 时间:2023-10-21 07:31
commit2: add test2.ccommit1: add test1.c模拟丢失commit记录的情况,执行git reset --hard HEAD~1,删除了commit3,同时test3.c文件已经在working tree里看不到了,如果要恢复commit3,就要使用git reflog和git cherry-pick.$ git reflog502dd0f HEAD@{0}: HEAD~1: updating HEAD147b3b5 HEAD@{1}: commit: test3502dd0f HEAD@{2}: commit: test20692c03 HEAD@{3}: commit (initial): test1HEAD@{0}: HEAD~1: updating HEAD红色加粗的即是被删除了的 commit3,运行git log则没有这一行记录,可以使用git reset --hard 502dd0f将红色记录删除,恢复cmmit3,需要用git cherry-pick.$ git cherry-pick 147b3b5[master 02c1e69] test30 files changed, 0 insertions(+), 0 deletions(-)create mode 1004 test3.c
热心网友 时间:2023-10-21 07:31
commit2: add test2.ccommit1: add test1.c模拟丢失commit记录的情况,执行git reset --hard HEAD~1,删除了commit3,同时test3.c文件已经在working tree里看不到了,如果要恢复commit3,就要使用git reflog和git cherry-pick.$ git reflog502dd0f HEAD@{0}: HEAD~1: updating HEAD147b3b5 HEAD@{1}: commit: test3502dd0f HEAD@{2}: commit: test20692c03 HEAD@{3}: commit (initial): test1HEAD@{0}: HEAD~1: updating HEAD红色加粗的即是被删除了的 commit3,运行git log则没有这一行记录,可以使用git reset --hard 502dd0f将红色记录删除,恢复cmmit3,需要用git cherry-pick.$ git cherry-pick 147b3b5[master 02c1e69] test30 files changed, 0 insertions(+), 0 deletions(-)create mode 1004 test3.c
热心网友 时间:2023-10-21 07:31
commit2: add test2.ccommit1: add test1.c模拟丢失commit记录的情况,执行git reset --hard HEAD~1,删除了commit3,同时test3.c文件已经在working tree里看不到了,如果要恢复commit3,就要使用git reflog和git cherry-pick.$ git reflog502dd0f HEAD@{0}: HEAD~1: updating HEAD147b3b5 HEAD@{1}: commit: test3502dd0f HEAD@{2}: commit: test20692c03 HEAD@{3}: commit (initial): test1HEAD@{0}: HEAD~1: updating HEAD红色加粗的即是被删除了的 commit3,运行git log则没有这一行记录,可以使用git reset --hard 502dd0f将红色记录删除,恢复cmmit3,需要用git cherry-pick.$ git cherry-pick 147b3b5[master 02c1e69] test30 files changed, 0 insertions(+), 0 deletions(-)create mode 1004 test3.c