您需要重新綁定並嘗試再次解決衝突。這可能很簡單,也可能稍微複雜一些。如果它很簡單,您只需要重新合併並修復已刪除的文件。試試這個:
git rebase -i HEAD~1
你會看到一個屏幕,詢問你想要對每個提交做什麼。 這將是這樣的:
pick bb009b7 merge commit
# Rebase 9775146..bb009b7 onto 9775146
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#
變化挑編輯,保存並退出編輯器。您現在又回到合併提交中。運行:
git checkout <id of the previous commit> <filename>
git commit --amend
git rebase --continue
這應該解決它。如果不這樣做,則需要進一步回溯,可能會更復雜。
我猜想,它會去是這樣的:
# rebase the last three commits, assuming:
# the oldest is your most recent changes
# the next is your co-worker's
# the last is the merge
# You can probably go back only two but I generally
# go back one extra just to see that things are as I
# expect.
git rebase -i HEAD~3
你會看到一個對話框,詢問呈現你想要做的每一個承諾什麼。 這將是這樣的:
pick 8d25cf0 Your changes
pick e9ddd29 His changes
pick bb009b7 merge
# Rebase 9775146..bb009b7 onto 9775146
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#
假期第一行是。在第二個改變選擇編輯。最後我想你也要編輯。
編寫並保存這個,並且rebase將開始。它將通過第一次提交併在第二次停止。你的文件應該丟失。您現在想運行:
git checkout <id of the previous commit> <filename>
而且這將恢復您的同事刪除的文件。
然後運行:
git commit --amend
git rebase --continue
當你到了合併提交只是檢查,以確保事情像您期望。如果文件丟失,請嘗試再次檢出。然後修改並繼續。你現在應該擁有你需要的一切。
如果你覺得事情在任何時候
git rebase --abort
會錯這將使你回到你開始的地方,你可以再次嘗試。
所以你說的是我需要重新綁定並強制推送到我們的遠程倉庫,並且還告訴所有參與者放棄並再次拖動這個分支? – 2012-03-15 17:36:38
我想你可以嘗試在當前提交中執行前一個提交> git checkout',只要在沒有這些文件的情況下提交歷史記錄不會被視爲問題。 –
Ilion
2012-03-15 17:47:33
我寧願有這些文件的歷史記錄,所以一旦我將重新開始工作,我將首先嚐試重新綁定。 – 2012-03-15 18:04:16