从git中恢复丢失的文件?撤消命令git reset --hard origin / master?

时间:2017-06-24 17:32:39

标签: git azure-devops

我错误地给了git reset --hard origin / master。当我运行'git reflog'它显示我最近的活动。我的下一个命令应该是什么来恢复丢失的文件?

MacMini3s-Mac-mini:Avacabs macmini1$ git reflog

1f666a8 (HEAD -> master, feature/AddingSegmentViews) HEAD@{0}: reset: moving to HEAD@{1}
73ae554 (origin/master, origin/feature/cardView, origin/HEAD) HEAD@{1}: reset: moving to HEAD@{1}
1f666a8 (HEAD -> master, feature/AddingSegmentViews) HEAD@{2}: reset: moving to HEAD@{1}
73ae554 (origin/master, origin/feature/cardView, origin/HEAD) HEAD@{3}: reset: moving to origin/master
1f666a8 (HEAD -> master, feature/AddingSegmentViews) HEAD@{4}: merge feature/AddingSegmentViews: Fast-forward
91a8d90 (origin/feature/Trip, feature/Trip) HEAD@{5}: checkout: moving from master to master
91a8d90 (origin/feature/Trip, feature/Trip) HEAD@{6}: checkout: moving from feature/AddingSegmentViews to master
1f666a8 (HEAD -> master, feature/AddingSegmentViews) HEAD@{7}: commit: Trip class Segments added. Tripsheet segment page pending and Trip confirmed segment icon pending
91a8d90 (origin/feature/Trip, feature/Trip) HEAD@{8}: checkout: moving from master to feature/AddingSegmentViews
91a8d90 (origin/feature/Trip, feature/Trip) HEAD@{9}: merge feature/Trip: Fast-forward
5eac266 (origin/feature/aravind, feature/aravind) HEAD@{10}: checkout: moving from feature/Trip to master
91a8d90 (origin/feature/Trip, feature/Trip) HEAD@{11}: commit: Going to start Trip class
5eac266 (origin/feature/aravind, feature/aravind) HEAD@{12}: checkout: moving from master to feature/Trip
5eac266 (origin/feature/aravind, feature/aravind) HEAD@{13}: merge feature/aravind: Fast-forward
f5095d7 HEAD@{14}: checkout: moving from feature/aravind to master
5eac266 (origin/feature/aravind, feature/aravind) HEAD@{15}: commit: Arvinth came
f5095d7 HEAD@{16}: checkout: moving from master to feature/aravind
f5095d7 HEAD@{17}: clone: from https://example.visualstudio.com/Avacabs/Avacab/_git/Avacabs

MacMini3s-Mac-mini:Avacabs macmini1$ 

1 个答案:

答案 0 :(得分:1)

git reset 'HEAD@{1}

如果显示"重置后的非暂停更改:"

DO

git add .

或查看this回答