2013-05-07 554 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