1

私は3台のマシンを持っています:

ラップトップ、デスクトップ、サーバー

私が取り組んでいるブランチは 2 つあります。next と regroup です。regroupは手付かずで、新しい次になってほしいです。

イベントのタイムライン:

 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 と regroup_final の下に必要なブランチがまだありますが、サーバー上でそれをリセットする方法がわかりません。

私がやりたいことは、デスクトップの再グループ化をサーバーの次のグループにすることです。サーバーに対して行った愚かなプッシュを完全に吹き飛ばしたい。私は混乱しています、そして私はいくつかの助けを借りることができます.

4

1 に答える 1

0
git merge -s recursive -X theirs regroup

これにより、競合が発生した場合に「自分のもの」が選択されます。ただし、「私たちの」競合しない変更は保持されます。

git reset --hard HEAD

これにより、作業ディレクトリの変更が取り消されます。ただし、マージは既にコミットされているため、おそらく何も取り消されていません。次のコマンドを使用して、最後のコミットをロールバックできます。

git reset --hard HEAD^

最後のポイントとして、そのコピー方法では、reset_finalコミットされていない変更はコピーされません。デスクトップにコミットされていない変更がありますか? 確認する:

git status
于 2013-05-10T14:43:41.840 に答える