亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

有沒有“他們”版本的“Git合并我們的”?

有沒有“他們”版本的“Git合并我們的”?

Git
長風秋雁 2019-07-02 14:51:08
有沒有“他們”版本的“Git合并我們的”?將主題分支“B”合并為“A”時使用git merge我有些矛盾。我知道所有的沖突都可以用“B”中的版本來解決。我知道git merge -s ours..但我想要的是git merge -s theirs.為什么不存在?在與現有的沖突合并之后,如何實現相同的結果?git命令?git checkout每個未合并的B文件)更新:僅僅丟棄分支A中的任何東西(合并提交點到B版本的樹)的“解決方案”不是我想要的。
查看完整描述

3 回答

?
縹緲止盈

TA貢獻2041條經驗 獲得超4個贊


一個可能的和經過測試的解決方案,用于將分支B合并到我們的簽出分支A中:


# in case branchA is not our current branch

git checkout branchA


# make merge commit but without conflicts!!

# the contents of 'ours' will be discarded later

git merge -s ours branchB    


# make temporary branch to merged commit

git branch branchTEMP         


# get contents of working tree and index to the one of branchB

git reset --hard branchB


# reset to our merged commit but 

# keep contents of working tree and index

git reset --soft branchTEMP


# change the contents of the merged commit

# with the contents of branchB

git commit --amend


# get rid off our temporary branch

git branch -D branchTEMP


# verify that the merge commit contains only contents of branchB

git diff HEAD branchB

要使其自動化,可以使用分支A和分支B作為參數將其包裝到腳本中。


此解決方案保留合并提交的第一個和第二個父級,正如您所期望的git merge -s theirs branchB.


查看完整回答
反對 回復 2019-07-02
  • 3 回答
  • 0 關注
  • 580 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號