簡體   English   中英

使用 git pull --rebase 時如何自動保留合並提交?

[英]How to preserve merge commits automatically while using git pull --rebase?

我想保留合並分支的分支信息,所以設置了branch.master.mergeoptions=--no-ff 這樣,即使可以快進,也總是會生成合並提交。

然而,一個副作用是在執行git pull時會創建一個合並提交(更具體地說:在 IntelliJ 或 Eclipse 中更新)。 為了防止日志充滿Merge remote-tracking branch 'origin/master' ,我還設置了branch.master.rebase=true ,這將在拉動origin/master時將master快進到origin/master

這個設置還有另一個副作用:當我將一個分支合並到master之后,我git pull因為我在合並之前忘記這樣做了,我的分支信息丟失了:特性分支在master被展平了。

命令git pull --rebase=preserve正是我所需要的:它將重新設置master ,然后再次應用分支的合並。 但我需要自動完成,因為這些命令中的大多數都是由 Eclipse 或 Intellij 執行的。 我希望git pull實際上執行一個git pull --rebase=preserve

有一個配置設置pull.rebase=preserve應該這樣做,但即使在我設置了這個配置之后, git pull也只會做一個git pull --rebase而不是預期的git pull --rebase=preserve ,而我當前使用 git 版本 2.12.2,預計將包含該功能。

那么我如何確保當我對我的主人做git pull時,即使我在合並之前沒有更新我的主人,它也會保留我的合並提交?

設置branch.master.rebase=true實際上覆蓋了默認的pull.rebase=preserve

解決方案是執行命令git config branch.master.rebase merges以便配置設置現在是branch.master.rebase=merges 這將在執行git pull時自動保留合並提交

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM