我在这个上搞得很糟糕。 我正在研究分支'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