简体   繁体   English

Git开发工作流程

[英]Git development workflow

I am still a bit new on Version Control systems. 我对版本控制系统还有点新意。

Currently I have two branches: master and develop . 目前我有两个分支: masterdevelop 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? 你如何在日常工作流程中使用git处理这些事情?

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. 我想向您推荐一篇成功的Git分支模型 ,它使用功能分支,开发分支,发布分支和hoxfixes来表示不同的目的。 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. 您可能感兴趣的另一个Git扩展是gitflow ,它为文章中的分支模型提供了高级存储库操作。

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. 在这个特定的情况下,我将从master中创建一个新的分支(称为ImproveUnitTests),然后在与您从开发中完成的主题相关的提交中进行挑选。 Then your ImproveUnitTests can easily be merged back into master on its own. 然后您的ImproveUnitTests可以很容易地自己合并回master。

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. 如果我正在开发featureX并且看到我需要修复其他内容,我将切换回我的主人并创建一个新的分支来修复那些东西。 Then merge my "fixit" branch into master, and rebase featureX off that. 然后将我的“fixit”分支合并到master中,并将rebase featureX关闭。

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 :) 在那种情况下,我会切换到主和樱桃挑选好的变化(单元测试更改),然后只需还原开发分支,并开心:)

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

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