发布功能分支以在 git 中定期预览

发布于 2024-12-08 23:11:35 字数 1268 浏览 3 评论 0原文

我试图了解偶尔将功能分支发布到 git 预览分支的最佳方式。这是我的设置:

  1. 客户要求提供功能。
  2. 我开发初始功能并发布到预览/测试站点。
  3. 客户提供反馈。
  4. 我做了更多的改变。
  5. 转到步骤 3 几次。
  6. 客户可以将
  7. Rebase 功能合并到推送到生产站点的单个提交中。

请注意,可能会同时开发几种不同的功能,并且只有一个“预览”站点,客户可以在其中看到正在开发的所有这些功能。我目前的 git 工作流程。

git checkout -b new_feature
...hack hack hack...
git add .
git commit -m "WIP"
git checkout preview
git merge new_feature
... feedback and another feature got approved and merged with master ...
git checkout new_feature
git merge master
... hack hack hack...
git add .
git commit -m "WIP"
git checkout preview
git merge new_feature
... client approves work for release ....
git checkout new_feature
git rebase -i master
... squash all commits except the first which I reword with a good description...
git checkout master
git merge new_feature
git branch -d new_feature
git checkout preview
git merge master
git checkout master

所以最终的结果是:

  1. 我能够在它自己的独立分支中开发该功能,并在其投入生产时进行控制。它还在生产中作为一个漂亮整洁的提交进行汇总。
  2. 客户可以在我开发该功能时看到该功能并提供反馈。他们还可以看到该功能以及我正在同时开发的其他功能。
  3. “预览”分支变得有点混乱,因为它同时获得“WIP”提交和最终的重新基准提交。但我并不介意,因为它只是用于客户端预览,如果我愿意,我可以定期删除分支并从 master 重新创建。

我唯一的问题是我遇到的冲突似乎比我预期的要多。我认为这是因为登台同时获得了开发提交和最终提交。我也想知道是否有更好的方法来做到这一点?

I'm trying to understand the best way to occasionally publish a feature branch into a preview branch for git. Here is my setup:

  1. Client asks for feature.
  2. I develop initial feature and publish to preview/testing site.
  3. Client provides feedback.
  4. I make more changes.
  5. Go to step 3 a few times.
  6. Client is good to go with feature
  7. Rebase feature into single commit pushed to production site.

Note that several different features may be developed at once and there is only one "preview" site where the client can see all these features as they are being developed. My git workflow currently.

git checkout -b new_feature
...hack hack hack...
git add .
git commit -m "WIP"
git checkout preview
git merge new_feature
... feedback and another feature got approved and merged with master ...
git checkout new_feature
git merge master
... hack hack hack...
git add .
git commit -m "WIP"
git checkout preview
git merge new_feature
... client approves work for release ....
git checkout new_feature
git rebase -i master
... squash all commits except the first which I reword with a good description...
git checkout master
git merge new_feature
git branch -d new_feature
git checkout preview
git merge master
git checkout master

So the end result:

  1. I was able to develop the feature in it's own isolated branch and control when it goes to production. It also is rolled up in production as a nice neat commit.
  2. The client can see the feature as I develop it and provide feedback. They can also see that feature along with other features I am developing simultaneously.
  3. The "preview" branch become a little messy as it gets both the "WIP" commits and the final rebased commit. But I don't mind that much as it is just for client preview and I can periodically delete the branch and re-create from master if I want.

My only problem is that I seem to get more conflicts than I would expect. I am thinking this is because staging is getting both the development commits and the final commit. I am also wonder if there is a better way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最偏执的依靠 2024-12-15 23:11:35

您的工作流程似乎很好,但我不喜欢在与主分支合并之前压缩功能分支中的所有提交。

在我看来,这不会增加任何价值,而且您会丢失有关功能演变的潜在重要信息。

当我合并时,我使用 git merge --no-ff new_feature 。这保留了有关功能分支是否存在的信息,以便您一目了然地知道每个功能都有哪些提交:

git merge - -no-ff

图片来源 - 成功的 Git 分支模型

Your workflow seems fine, except I don't like squashing all the commits from your feature branch before merging with master.

In my opinion, this doesn't add any value, and you lose potentially important information about the evolution of the feature.

When I merge, I use git merge --no-ff new_feature. This preserves information about the existence of a feature branch so that at a glance you will know which commits went into each feature:

git merge --no-ff

Image source - A successful Git branching model

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文