2013-05-07 557 views
2

我有github分支,当主分支达到某种可接受的状态(做过一次)时,我推送给github。为此我做了:git merge squash - 冲突解决当我想要的是我从分支的变化我从

[email protected] /c/Dropbox/eclipse_workspaces/android/AndroidMonitoring (master) 
$ git checkout github 
Switched to branch 'github' 
[email protected] /c/Dropbox/eclipse_workspaces/android/AndroidMonitoring (github) 
$ git merge --squash master 
Auto-merging src/gr/uoa/di/monitoring/android/services/Monitor.java 
CONFLICT (add/add): Merge conflict in src/gr/uoa/di/monitoring/android/services/ 
Monitor.java 
//... 
Automatic merge failed; fix conflicts and then commit the result. 

我想是刚刚在同一状态下的工作目录正是作为主HEAD。

  • 是我的做法错误的方式(反复合并--squashing到github分支)。
  • 有没有一种简单的,可以防止白痴的方式来达到这个目的(不经历每次冲突)。
  • 作为奖励,我想知道是什么使用本地版本使用远程版这个PIC的意思是 - msysgit:

    enter image description here

+0

_I想知道有什么用本地版本,并使用远程版本指本PIC工作 - msysgit_:这仍然是一个神秘 – 2013-07-18 20:28:04

回答

3

好了很多谷歌搜索后,结果证明我的策略是错误的。 git merge --squash没有做我想做的事 - 即将我的主分支镜像到我的github分支,但没有保留master的提交历史(一个简单的合并会做,但我不想在github中有任何主人的历史)。
对于一个不会删除已删除的文件 - 一个不错的说明,请参见here
可能有其他缺陷 - 包括永恒冲突的决议,can't be avoided

无论如何,我想我找到了正确的方式 - 一个详细here

$ git checkout [email protected]{0} 
$ git reset --soft github 
$ git commit 
$ git branch temp 
$ git checkout temp 
$ git branch -M github 
$ git push -u -v origin github:master 

试了一下,确实,因为我想

1

你必须跟进git merge --squashgit commit,所以您的工作流程中可能有错误。

您可以使用git merge -s theirs指定您总是希望其他主分支在这种情况下赢得所有合并冲突。 (虽然我很惊讶,如果你在github分支上没有单独的工作,你会得到合并冲突)

+0

要提交我首先要解决冲突 - 但这些合并冲突是我所追求的(也是在徘徊) – 2013-05-07 18:14:06

+0

如果您没有提交任何内容但合并到github分支,我会重置当前合并并启动它再次。 'git reset --merge'很好地工作。 – 2013-05-07 18:16:14

+0

我没有什么区别 - 仍然出现冲突 – 2013-05-07 18:18:54