git 发布管理

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1042400/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:44:45  来源:igfitidea点击:

git releases management

gitrelease

提问by Maciej Lotkowski

I couldn't find anything what is the "right" approach to manage the releases using git. Say, I have master, release-1, release-2 and release-3 branches. Release 1 is already released and I do only bugfixing and released versions tagging on it. Release 2 is going to be released soon and I develop mostly on this branch while on 3 I develop things which will be needed in the further future.

我找不到任何使用 git 管理发布的“正确”方法。比如说,我有 master、release-1、release-2 和 release-3 分支。第 1 版已经发布,我只做错误修复和发布版本标记。第 2 版即将发布,我主要在这个分支上进行开发,而在第 3 版中,我开发了将来需要的东西。

  1. When I add some feature on release-2 and it should go to 3 as well, but not to 1, should I:

    • merge release-2 to master and cherry-pick feature related commit to release-3?
    • cherry-pick feature related commit to master and than cherry-pick it to release-3?
    • sth else?
  2. When I need to changes sth in all the versions, should I do it on master and cherry-pick it to all the branches?

  3. Should I keep master up to date with the newest(release-3 branch) or rather developer on release-3 and merge to the master just before I will need release-4 branch?

  4. When I fix sth on release-1 or release-2, should I merge or cherry-pick it to master or rather?

  1. 当我在第 2 版上添加一些功能并且它也应该转到 3 而不是 1 时,我应该:

    • 将 release-2 合并到与 release-3 相关的 master 和cherry-pick 功能提交?
    • 樱桃挑选功能相关的提交给主人,而不是樱桃挑选它到版本3?
    • 还有什么?
  2. 当我需要在所有版本中更改某事时,我是否应该在 master 上进行并挑选它到所有分支?

  3. 我应该让 master 保持最新的(release-3 分支)还是 release-3 上的开发人员并在我需要 release-4 分支之前合并到 master?

  4. 当我在 release-1 或 release-2 上修复某个东西时,我应该合并还是挑选它来掌握它还是更确切地说?

I'm not quite sure when should I cherry-pick, when should I merge and if the flow of the code between the branches it right.

我不太确定什么时候应该挑选,什么时候应该合并,以及分支之间的代码流是否正确。

回答by Jakub Nar?bski

See the following posts on Junio C Hamano (git maintainer) blog:

请参阅 Junio C Hamano(git 维护者)博客上的以下帖子:

Take also look at gitworkflowsmanual page.

另请查看gitworkflows手册页。

回答by VonC

What you are asking is a typically a merge workflowproblem: what to merge from where to where.

您要问的是典型的合并工作流问题:从何处合并到何处。

But you also need to remember that in a DVCS, a merge will also be influence by publication considerations(are those branches pushed to local repositories, or public ones)

但是您还需要记住,在 DVCS 中,合并也会受到发布考虑因素的影响(那些分支是推送到本地存储库还是公共存储库)

"master" branch in particular is the one visible by default when someone clone your repo, meaning it should reference what you consider most useful to that user/developer. (since other branches are not referenced locally by default)

“主”分支尤其是当有人克隆您的存储库时默认可见的分支,这意味着它应该引用您认为对该用户/开发人员最有用的内容。(因为其他分支默认情况下不在本地引用



1/ When I add some feature on release-2 and it should go to 3 as well, but not to 1

1/ 当我在第 2 版上添加一些功能时,它也应该是 3,而不是 1

You can indeed merge r2 to master, after having made a number of commits to r2 in order to achieve the necessary evolutions. That way, only a limited number of commits are visible in master, avoiding "commit cluttering".
For r3 however, you can cherry pick what you need from r2, if r3 is being pushed and published. Otherwise, you could rebase r3 on r2. See "git workflow and rebase vs merge" question

在对 r2 进行多次提交以实现必要的演变之后,您确实可以将 r2 合并到 master。这样,在 master 中只能看到有限数量的提交,避免“提交混乱”。
但是,对于 r3,如果 r3 正在推送和发布,您可以从 r2 中挑选您需要的内容。否则,您可以在 r2 上重新设置 r3。请参阅“ git 工作流程和变基与合并”问题

2/ When I need to changes sth in all the versions, should I do it on master and cherry-pick it to all the branches?

2/当我需要在所有版本中更改某事时,我是否应该在master上进行并挑选它到所有分支?

You should do it on r2, and then merge on master and r1 and r3. That way, only one commit is added to those branches.

你应该在 r2 上做,然后在 master 和 r1 和 r3 上合并。这样,只有一个提交被添加到这些分支。

3/ Should I keep master up to date with the newest(release-3 branch) or rather developer on release-3 and merge to the master just before I will need release-4 branch?

3 / 我应该让 master 保持最新的(release-3 分支)还是 release-3 上的开发人员并在我需要 release-4 分支之前合并到 master?

It depends on what you want your other colleague to see when they clone the repo.
But from 1/, I gather master is representing r2 (current development) and not r3 (future, long-term refactoring)

这取决于您希望其他同事在克隆存储库时看到什么。
但是从 1/ 开始,我认为 master 代表的是 r2(当前开发)而不是 r3(未来的长期重构)

4/ When I fix sth on release-1 or release-2, should I merge or cherry-pick it to master or rather?

4/ 当我在 release-1 或 release-2 上修复某个东西时,我应该合并还是挑选它来掌握它还是更确切地说?

  • r1: cherry-pick: not all what you are fixing on r1 is meant to be merged to current development.
    Actually, I would rather cheery-pick r1 fixed on r2, make sure everything work there, and then merge on master.
  • r2: merge. If master represents r2, a simple merge is enough.
  • r1:cherry-pick:并非您在 r1 上修复的所有内容都旨在合并到当前的开发中。
    实际上,我更愿意将 r1 固定在 r2 上,确保一切正常,然后在 master 上合并。
  • r2:合并。如果 master 代表 r2,那么简单的合并就足够了。

回答by Marius K

I would do:

我会做:

1) Merge r2 to master and then master to r3 (r3 should be able to accept all changes to master)

1)将r2合并到master然后master到r3(r3应该能够接受所有变化到master)

2) Commit to r1, merge to r2, merge r2 to master and then merge master to r3

2)commit到r1,合并到r2,合并r2到master,再合并master到r3

3) Maybe you should use master instead of r3, and only develop on branch off r3 when the release is under preparation and merge up all changes here to master (which will be the next version). Or use "master" and "next" branch as Linux.

3)也许你应该使用master而不是r3,并且只有在准备发布时才在r3的分支上进行开发并将这里的所有更改合并到master(这将是下一个版本)。或者像 Linux 一样使用“master”和“next”分支。

4) Merge to master

4)合并到master

I think merging is cleaner than cherry-picking and think you should only cherry-pick when you need to backport a feature or bugfix to an older branch that you did not expect when the commit was made (else commit on the oldest branch/release you want the code on).

我认为合并比挑选更干净,并且认为只有当您需要将功能或错误修复向后移植到您在提交时没有预料到的旧分支时才应该挑选(否则在最旧的分支上提交/释放您想要代码)。