2016-01-21 64 views

回答

0

首先,複製你正在工作的文件夾,以防萬一有什麼不好的事情發生。 Git通常非常防彈,但如果你開始使用git reset --hard,那麼可能會發生不好的事情。

然後,做一個git commit --patch,只挑選你想保留的變化,並留下合併所做的一切。一旦你已經提交這些更改,請執行git reset --hard,並且合併應該消失,但是你的更改應該仍然存在。

+0

它不詢問合併的東西。當你到達提交信息時,你最終會得到一切。 – detly

+0

@detly這種情況發生,即使你開始沒有任何階段,然後階段改變只有'git commit --patch'或'git add --patch'? – ddsnowboard

2

語言是不明確的。 :-)當你說「保留本地修改」您的意思可以:

  1. 保持在工作目錄中的所有電流的變化,無論你手動編輯那些你在帶來他們中間文件或合併;或
  2. 放棄合併帶來的任何更改並保留您所引入的任何更改。

這種簡單的解決方案地址點(1):

$ git stash save 
$ git stash pop 

這裏的成績單顯示影響:

$ git status 
On branch stuff-217/apply-new-config-details 
All conflicts fixed but you are still merging. <<<<<< notice this line! 

Changes to be committed: 
     modified: package.json 
     modified: src/wallabyTest.ts 
     modified: wallaby.js 

$ git stash save 
Saved working directory and index state WIP on stuff-217/apply-new-config-details... 

$ git status 
On branch stuff-217/apply-new-config-details 
nothing to commit, working tree clean 

$ git stash pop 
On branch stuff-217/apply-new-config-details 
              <<<<<< no longer in the merge! 
Changes not staged for commit: 
     modified: package.json 
     modified: src/wallabyTest.ts 
     modified: wallaby.js