这是我的git log
$ git log
commit b5865d75efbd7bdf5b28aef6526f96ebd971e95c
Author: user <user@example.com>
Date: Mon Mar 31 21:20:17 2014 -0400
new work
commit 7ee27d135a733fe709279f7752f5844da3102f9e
Author: user <user@example.com>
Date: Mon Mar 31 20:44:33 2014 -0400
added password_for_form_show to attr_accessor
commit f3decd1232c6884c14cd082c3129e77ddd2b3bab
Author: user <user@example.com>
Date: Mon Mar 31 14:21:36 2014 -0400
phase 3.5
commit 99804b8f0adc572021f773dea5e660186d11a88b
Author: user <user@example.com>
Date: Mon Mar 31 12:19:13 2014 -0400
jquery stuff done
我刚从我的分支机构检查了最新的提交
git checkout b5865d75efbd7bdf5b28aef6526f96ebd971e95c
上述提交发布在github上。
我下次尝试这样做
git revert HEAD~3
我想永久地在本地和github上恢复到这个阶段
commit 99804b8f0adc572021f773dea5e660186d11a88b
Author: user <user@example.com>
Date: Mon Mar 31 12:19:13 2014 -0400
jquery stuff done
当我执行上述命令时,我得到了这个
error: 'revert' is not possible because you have unmerged files.
当我做的时候
git status
我收到了这个
$ git status
# HEAD detached at b5865d7
# You are currently reverting commit 99804b8.
# (fix conflicts and run "git revert --continue")
# (use "git revert --abort" to cancel the revert operation)
#
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: app/controllers/users_controller.rb
#
# Unmerged paths:
# (use "git reset HEAD <file>..." to unstage)
# (use "git add <file>..." to mark resolution)
#
# both modified: app/views/users/trial_signup.html.erb
请注意,我也不想要我的本地提交/文件。我如何强制恢复?我不想隐藏它们,因为我不想要它们。我不想提交,添加和推送。
答案 0 :(得分:0)
实际上,当您执行还原时,git会主持 new 提交,否定主题提交中所做的更改,并尝试在当前HEAD之上应用新更改。当然,现阶段可能存在合并冲突。您必须通常解决它们,然后提交新的更改。可能你需要一个篮板?