Git 开发工作流程

发布于 2024-11-02 12:19:10 字数 316 浏览 1 评论 0原文

我对版本控制系统还是有点陌生​​。

目前我有两个分支:masterdevelop。昨天我正在开发分支上工作,并意识到我所做的事情是错误的,所以我不得不切换回一些旧的提交。

问题是,在最近的提交中,我添加了一些新的单元测试,并显着改进了一些关键的单元测试基础设施类,即使在回到旧的提交之后,我也希望将其保留在我的项目中。

这让我意识到,也许我从一开始就应该做的是拥有一个与所有“项目相关”而不一定与“当前功能”相关的功能相关的分支。我说得对吗?

在日常工作流程中,你如何使用 git 处理这些事情?

I am still a bit new on Version Control systems.

Currently I have two branches: master and develop. Yesterday I was working on the develop branch and came to realize that what I've made was wrong, so I had to switch back to some older commit.

The problem is that in recent commits I've added a couple of new unit-tests and improved considerably some key unit-testing infrastructure classes, that I'll want to keep in my project, even after coming back to an older commit.

This made me realize that maybe what I should have done since the beginning is having a branch related to all those features that are "project related" and not necessarily "current feature" related. Am I right?

How do you handle such things in your daily workflows w/ git?

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

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

发布评论

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

评论(3

咽泪装欢 2024-11-09 12:19:10

我想向您推荐这篇文章成功的 Git 分支模型 ,它使用特性分支、开发分支、发布分支和hoxfixes来代表不同的目的。您可能感兴趣的另一个 Git 扩展是 gitflow,它为分支模型提供高级存储库操作文章中提到。

I would like to recommend the article A successful Git branching model to you, it uses feature branches, develop branch, release branches, and hoxfixes to represent different purpose. And another Git extension you may have interest in is gitflow, it provides high-level repository operations for the branching model mentions in the article.

童话里做英雄 2024-11-09 12:19:10

在这种特定情况下,我将从 master 创建一个新分支(称为 ImproveUnitTests),然后在与您在开发中完成的该主题相关的提交中进行挑选。然后,您的 ImproveUnitTests 可以轻松地自行合并回 master 中。

对于日常工作,我使用很多分支。如果我正在开发 featureX 并发现需要修复其他问题,我将切换回我的 master 并创建一个新分支来修复这些问题。然后将我的“fixit”分支合并到 master 中,并重新设置 featureX 的基础。

In this specific case, I'd create a new branch (called ImproveUnitTests) from master then cherry-pick in the commits related to that topic that you've done from development. Then your ImproveUnitTests can easily be merged back into master on its own.

For day-to-day stuff I use a LOT of branches. If I'm developing featureX and see that I need to fix something else, I'll switch back to my master and make a new branch just to fix that stuff. Then merge my "fixit" branch into master, and rebase featureX off that.

不羁少年 2024-11-09 12:19:10

如果我的理解是正确的,您想要恢复您的更改,但保留其中一些。在这种情况下,我会切换到 master 并挑选好的更改(单元测试更改),然后恢复开发分支并感到高兴:)

If I get you right you want to revert your changes, but keep some of them. In that case I would switch to master and cherry pick the changes that was good (the unit test changes) and then just revert the develop branch and be happy :)

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