我已將master
合併到我的bugXY
分支中,並且需要合併文件。但git mergetool
失敗(我猜我是noob錯誤),即使我中止了合併,它留下了一個骯髒的工作目錄,但不需要合併狀態。我想重複合併命令,但我不能因爲合併留下一些新文件。git在撤消失敗合併時刪除文件
我該如何撤消合併(我沒有提交任何內容),並從以前得到完全的工作目錄?
我做了什麼:
> git checkout bugXY
On branch "bugXY" - nothing to commit
> git merge master
[modifying and adding lots of files]
one file with conflict
On branch "bugXY|MERGING"
> git mergetool
You could use a, b or c
merged // didn't work, no GUI appeared and I did not do anything
do you want to remove, commit or abort?
> abort // Hu, what happened?
On branch "bugXY" // no MERGING any more???
哎呀,我做了什麼?重複的git merge
不起作用,我已經更改(並暫存)了我的工作目錄中的文件。好的,撤消它。我想:
> git reset --hard HEAD
和
> git checkout bugXY
現在沒有上演任何更多,但我還是有一堆未跟蹤工作樹中的文件妨礙我git merge
再次(「將被覆蓋,請[移動]「)。我怎樣才能做到這一點?我想rm path/to/file.php
每個人都會工作,但有很多他們...
運行第二個命令時要小心......或者你的IDE有一個本地歷史記錄功能 – Carlton