2013-05-10 77 views
1

我有3臺機器:我犯了一個git錯誤,我似乎無法修復它。

筆記本電腦,臺式機,服務器

有兩個分支我的工作:未來和重組。重組是原始的,我希望它成爲下一個新的。

事件發生的時間:

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的分支,但我不知道如何將其重置爲服務器上的分支。

我想要做的是讓我的桌面重新組合服務器的下一個。我想完全吹走我對服務器所做的愚蠢推動。我很困惑,我可以使用一些幫助。

回答

0
git merge -s recursive -X theirs regroup 

這將在出現衝突時選擇「他們的」。但是「我們」的非衝突性變化仍然存在。

git reset --hard HEAD 

這將撤消工作目錄中的任何更改。但是,由於您的合併已經提交,因此可能不會撤消任何操作。你可以回退最後要提交:

git reset --hard HEAD^ 

爲了您的最後一點,複製reset_final不會複製未提交變更的方式。您的桌面上是否存在未提交的更改?請與:

git status 
+0

有沒有無可爭議的變化。重置 - 硬HEAD ^沒有工作。看起來好像是在下一個提交樹的前一部分做出了改變,其中重寫了重組的東西。 – Erotemic 2013-05-10 16:08:41

相關問題