发布功能分支以在 git 中定期预览
我试图了解偶尔将功能分支发布到 git 预览分支的最佳方式。这是我的设置:
- 客户要求提供功能。
- 我开发初始功能并发布到预览/测试站点。
- 客户提供反馈。
- 我做了更多的改变。
- 转到步骤 3 几次。
- 客户可以将
- 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
所以最终的结果是:
- 我能够在它自己的独立分支中开发该功能,并在其投入生产时进行控制。它还在生产中作为一个漂亮整洁的提交进行汇总。
- 客户可以在我开发该功能时看到该功能并提供反馈。他们还可以看到该功能以及我正在同时开发的其他功能。
- “预览”分支变得有点混乱,因为它同时获得“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:
- Client asks for feature.
- I develop initial feature and publish to preview/testing site.
- Client provides feedback.
- I make more changes.
- Go to step 3 a few times.
- Client is good to go with feature
- 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:
- 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.
- 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.
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的工作流程似乎很好,但我不喜欢在与主分支合并之前压缩功能分支中的所有提交。
在我看来,这不会增加任何价值,而且您会丢失有关功能演变的潜在重要信息。
当我合并时,我使用 git merge --no-ff new_feature 。这保留了有关功能分支是否存在的信息,以便您一目了然地知道每个功能都有哪些提交:
图片来源 - 成功的 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:Image source - A successful Git branching model