2016-01-21 71 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