我犯了一个git错误,我似乎无法修复它。

时间:2013-05-10 14:36:02

标签: git

我有3台机器:

笔记本电脑,台式机,服务器

我正在使用两个分支:next和重新组合。重组是原始的,我希望它成为新的下一个。

事件时间表:

 1. I finish the last changes to regroup on Desktop and push them to Server
 2. I pull from server to laptop
 3. On, laptop I checkout next (next happens to be 2 commits ahead of server/next)
 // I want to take all the regroup changes and completly overwrite the next changes. 
 // I think this command will work (i'm not actually sure what it really did)
 4. Laptop: git merge -s recursive -X theirs regroup
 5. Laptop: git push
 6. Oh no, I forgot to test before push. Quick test. Things break. 
 7. Laptop: git checkout regroup; git reset --hard HEAD. Test. Things still break. 
 // Ok, I'll just switch to my desktop whichi still works, and get that perfect branch back. 
 8. Desktop: Test, things still work. git checkout -b reset_final; git push origin reset_final
 10. Laptop: git pull; git checkout reset_final. Test. Things still break!? Why!?

所以,现在,我的服务器和笔记本电脑似乎搞砸了。我的桌面仍然有重新组合和regroup_final下的分支,但我不知道如何将其重置为服务器上的分支。

我想做的是让我的桌面重新组合服务器的下一个。我想完全吹掉我对服务器所做的愚蠢推动。我很困惑,我可以使用一些帮助。

1 个答案:

答案 0 :(得分:0)

git merge -s recursive -X theirs regroup

当发生冲突时,这将选择“他们的”。但是,“我们的”不存在冲突的变化。

git reset --hard HEAD

这将撤消工作目录中的任何更改。但是,由于您的合并已经提交,因此它可能没有撤消任何内容。您可以使用以下命令回滚上次提交:

git reset --hard HEAD^

对于您的最后一点,这种复制reset_final的方式不会复制未提交的更改。您的桌面上是否有未提交的更改?检查:

git status