简体   繁体   English

合并/变基工作流程

[英]Merge/rebase workflow

I am in the process of changing my git-merge-workflow and encountered following problem: 我正在更改git-merge-workflow的过程中遇到以下问题:

Up to now, i have been merging (--no-ff) my changes on the develop branch back to master whenever i released a new version. 到目前为止,每当我发布新版本时,我就一直将(--no-ff)在develop分支上的更改合并回master This generated a new merge-commit containing the history (--log) of all the develop -commits. 这将生成一个新的merge-commit,其中包含所有develop -commits的历史记录(--log)。 I realized that this is sub-optimal, and want to actually do fast-forward merges from my develop branch to master (having changed my commit-messages on develop to reflect my changes in a "cleaner" way). 我意识到,这是次优的,并希望真正做到快进从我的合并develop分公司master (已经改变我犯下的消息develop ,以反映一个“干净”的方式我的变化)。

My current problem: The most recent commit on master is a still a merge-commit from the last time, due to that I can't do an ff-merge from develop to master now, since the 2 branches "diverged" (the merge-commit is missing on develop ). 我当前的问题:最近一次对master的提交仍然是最后一次的merge-commit,因为我不能从developmaster进行ff-merge,因为2个分支“发散了”(合并-commit上缺少develop )。

My idea to solve this would have been, being on develop: git rebase master , which would pull in this merge-commit, and then enable me to do a git merge develop on master. 我想解决这个问题的想法是在开发中: git rebase master ,它将拉入这个merge-commit,然后使我能够在master上进行git merge develop But would this generate a new commit on develop (this particular merge-commit) or will git be smart enough to recognize that the changes of this merge-commit are already part of develop ? 但是,这会产生一个新的提交上develop (这个特别的合并提交)或将Git的足够聪明,认识到这种变化的合并提交已经部分develop

git rebase master while on develop will work fine for your purposes. git rebase masterdevelop会很好地满足您的目的。

If your branches are currently like this: 如果您的分支当前是这样的:

A-B-C-D-E <-- master
       /
  F-G-H-I-J <-- develop

then they'll wind up like this (because IJ is the only bit not reachable from E ): 然后它们就会像这样结束(因为IJ是从E IJ的唯一位):

A-B-C-D-E <-- master
         \
          I'-J' <-- develop

which will then fast-forward merge back into master like this: 然后,它会像下面这样快速合并回master:

A-B-C-D-E-I'-J' <-- master

Your method should allow it to work. 您的方法应该允许它工作。 Another way you can tackle this of course is to remove your develop branch completely at the next merge to master in case rebasing failed. 当然,您可以解决此问题的另一种方法是在下一次合并时完全删除您的developer分支,以防重新部署失败。 Then just branch off a new develop from master and rebase from that point onwards. 然后,从master分支出一个新的开发,并从那时起重新建立基础。

At my previous company we tried to switch our workflow from merging to rebasing as well. 在我以前的公司中,我们也尝试将工作流程从合并切换到重新定基。 But it ended up having all sorts of weird issues from merging of different branches. 但是最终由于合并不同的分支而出现了各种奇怪的问题。 It just felt cleaner and safer to start anew on the develop branch directly from master. 直接从master重新开始在development分支上感觉更干净,更安全。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM