![](/img/trans.png)
[英]In which cases git merge --no-ff is not keeping the commit history?
[英]Git merge -no-ff transferred commit history, but not content
在 GitLab 中遇到了一個錯誤。 我的一個項目有 50 多個模塊。 因此,當我合並分支時,我使用 bash 腳本,而不是使用 GitLab 合並 UI。 到目前為止,這工作得很好。 這次我遇到了一個奇怪的問題。 合並提交將提交歷史從源分支傳輸到目標分支,但不傳輸源分支的內容。 我試圖將分支 cr_integrate 合並到分支 cr_release。 在本地,我檢查了 cr_release。
我用於合並的腳本如下:
git pull
git merge --no-ff origin/cr_integrate -s ours
git add *
git commit -m "Integrate merged into Release by script"
git push
項目包含子模塊,不同分支的.gitmodules文件內容不同,所以我使用-s ours來避免沖突。 腳本有問題還是 GitLab 的錯誤?
因此我使用
-s ours
來避免沖突
但是-s ours
不是解決沖突的策略。 這是一種合並策略。
我喜歡閱讀文檔:
ours
的合並策略......甚至根本不看另一棵樹包含的內容。 它丟棄了其他樹所做的一切,聲明我們的歷史包含其中發生的一切。
[強調我的]
所以,現在,你說:
合並提交將提交歷史從源分支傳輸到目標分支,但不傳輸源分支的內容。
是的。 因為那是你說要做的。 也許您的意思是-s recursive -X ours
? 這是一種解決沖突的策略。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.