我在這個上搞得很糟糕。 我正在研究分支'feature1-branch'並提交了更改,但未將它們與主分支合併。如何恢復到Git中較舊的提交?
的git的日誌顯示是這樣的:
git log
commit 0829f9f0b68ce58ca37efd4e07cf3e8b3b67ed49
Date: Thu Apr 21 00:38:58 2011 -0700
feature1-branch lots and lots of changes
我不知道我在想什麼,但我所做的:
git checkout master
這刪除了一堆與分支添加新文件的優點1 -科'。
現在git的狀態顯示:爲刪除提到
git status
# On branch feature1-branch
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: app/controllers/activations_controller.rb
# deleted: app/controllers/settings_controller.rb
# modified: app/controllers/application_controller.rb
# deleted: app/controllers/products_controller.rb
的文件是不存在了。 如何讓他們回來的地方,我是在狀態犯
0829f9f0b68ce58ca37efd4e07cf3e8b3b67ed49
我很擔心,如果這些文件已經一去不復返了。
感謝您的幫助。
添加額外的信息:
git log -1 feature1-branch
commit 0829f9f0b68ce58ca37efd4e07cf3e8b3b67ed49
Date: Thu Apr 21 00:38:58 2011 -0700
feature1-branch lots and lots of changes
這是什麼混帳結賬回報:
git checkout feature1-branch
D app/controllers/activations_controller.rb
D app/controllers/products_controller.rb
M app/controllers/application_controller.rb
git的狀態返回:
git status
# On branch feature1-branch
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
# # deleted: app/controllers/activations_controller.rb
# deleted: app/controllers/products_controller.rb
no changes added to commit (use "git add" and/or "git commit -a")
謝謝馬克。那樣做了。我意外地運行git checkout master並按下ctrl-c時,我意識到發生了什麼事情。那整個事情搞糟了。你和Noufal都有很大的幫助,只要我可以給你們買一兩杯啤酒:) – truthSeekr 2011-04-21 08:33:16
我是一個茶壺,但是感謝你的祝福。 :) – 2011-04-21 08:38:52
@truthSeekr:沒問題:)如果您嘗試在沒有足夠磁盤空間的情況下嘗試「git結帳」,可能會出現類似混淆狀態...... –
2011-04-21 10:00:55