2016-12-14 36 views
1

是的,對不起,我在git上有點小氣,但是我把我的分支(branchA)合併到不同的分支(branchB)並將它推到遠程。我應該將它與分支C合併。現在我想恢復它,只是撤消由branchA到branchB所做的所有更改。有沒有辦法做到這一點? D:我將我的分支合併到錯誤的分支並推送它。有沒有辦法讓我只恢復那個分支的變化?

+0

的可能的複製[如何恢復合併提交一個已經被推到遠程分支?](http://stackoverflow.com/questions/7099833/how-to-revert-a-merge-commit-thats -already推到遠程分支) – Dunno

回答

1

你可以select the commit-hash,你想回去。然後通過hard reset刪除所有更改。然後執行force push,它將用您的local/branchB取代​​。

$ git checkout branchB 
$ git log       # copy the commit-hash you want to back 

# go back to a specific commit of branchB 
$ git reset --hard <commit-hash> 
$ git push -f origin HEAD   # force push, replace remote/branchB by local/branchB 
相關問題