我提交了一些文件後,本地文件被更改。現在我想恢復本地目錄與上次提交完全相同。在下圖中,本地未提交的更改已損壞,因此我想取出主基本操作員....我已嘗試git reset [the first commit hash code from git log]
,但沒有任何更改。git如何恢復上次提交文件
1
A
回答
1
git reset <commit>
改變您的HEAD點,但不會將您的文件恢復到他們是如何在這個承諾。如果你想將文件還原到它的外觀在提交時,需要git reset --hard <commit>
關於三種復位模式:
--soft
Does not touch the index file or the working tree at all (but
resets the head to <commit>, just like all modes do). This
leaves all your changed files "Changes to be committed", as git
status would put it.
--mixed
Resets the index but not the working tree (i.e., the changed
files are preserved but not marked for commit) and reports what
has not been updated. This is the default action.
If -N is specified, removed paths are marked as intent-to-add
(see git-add(1)).
--hard
Resets the index and working tree. Any changes to tracked files
in the working tree since <commit> are discarded.
0
我要恢復的本地目錄完全一樣,最後時間提交。在下圖中,當地未提交的修改損壞
如果你要放棄你的本地提交的更改然後做reset HEAD
(回到上次提交)
$ git reset --hard HEAD
相關問題
- 1. GIT:恢復上次提交?
- 2. 在git中,如何將文件恢復爲3次提交前?
- 3. Git:如何通過一次提交恢復一系列提交
- 4. 恢復git提交
- 5. git:從提交恢復文件
- 6. 恢復git中的多次提交
- 7. git checkout文件名恢復了我最後一次提交
- 8. 恢復git回購倒數第二次提交,同時拋棄上次提交
- 9. 如何恢復本地提交git
- 10. Git + Intellij - 如何恢復本地提交?
- 11. 如何恢復從git提交更改?
- 12. Git如何恢復舊提交
- 13. 如何恢復初始git提交?
- 14. 如何在git中恢復提交?
- 15. Git恢復本地提交
- 16. Git:恢復舊的提交
- 17. git恢復已提交的提交
- 18. 在Git中,如何恢復提交之前恢復的分級文件?
- 19. 如何恢復未在git中提交的隱藏文件?
- 20. 如何使用git恢復回到第三次提交?
- 21. hg:如何恢復(單個文件)多次提交?
- 22. 如何從git上丟失的提交中恢復代碼?
- 23. 如何恢復兩次提交併只提交好東西?
- 24. 如何恢復SVN提交?
- 25. 從早先的git合併中恢復已恢復提交的文件
- 26. Git:提前一次提交頭文件
- 27. Git - 如何返回上次提交併刪除所有未提交的文件?
- 28. 恢復Git倉庫/提交等
- 29. git恢復到某個提交
- 30. 恢復(沒有分支)git提交
後的git的復位 - 硬[提交哈希碼]我注意到自上次提交後添加的文件仍然存在。 – Tiina
@Tina:reset --hard將不會刪除自上次提交以來添加的任何新文件,因爲您尚未(尚未)告知git「觀察」這些文件。從某種意義上說,git不會以某種方式知道它們 - 它只關心你告訴你的文件。 –