git flow - 如何暂停一项功能的开发以处理另一项功能

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8581609/
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 06:16:07  来源:igfitidea点击:

git flow - how do I pause development on one feature to work on another

gitgit-flow

提问by John Green

I'm new to git and git flow. I've read all the various pages, blogs, and stackoverflow questions on it,and have been using it in my daily development.

我是 git 和 git flow 的新手。我已经阅读了所有关于它的页面、博客和 stackoverflow 问题,并且一直在我的日常开发中使用它。

But one issue has been bothering me, I just can't wrap my head around it. I know feature branches are supposed to be small, you start a feature, code a part of it, then finish the feature. This is a daily occurence, I get that. We just make sure that our develop branch is always buildable.

但是有一个问题一直困扰着我,我就是无法解决它。我知道功能分支应该很小,你开始一个功能,编码它的一部分,然后完成这个功能。这是每天都会发生的事情,我明白了。我们只是确保我们的开发分支始终是可构建的。

But what happens when I'm in the middle of a feature, it isn't ready to be finished, but work priorities change? I'd like to be able to switch to another feature.

但是,当我在做一个功能时,它还没准备好完成,但工作优先级发生了变化,会发生什么?我希望能够切换到另一个功能。

For example, I start a new feature.

例如,我启动了一个新功能。

$ git flow feature start yak-Speedup

I write code, commit files, etc... and am making good progress on it. But now I need to change what I am working on, mostly like because I need a resource that isn't available and the server coder won't have it ready for a day or two. I can't finish the feature because it will break the develop branch.

我编写代码、提交文件等……并且在这方面取得了良好的进展。但现在我需要改变我正在做的事情,主要是因为我需要一个不可用的资源,而服务器编码器在一两天内无法准备好。我无法完成该功能,因为它会破坏开发分支。

I'd like to do something like this:

我想做这样的事情:

$ git flow feature pause yak-Speedup
$ git flow feature start alpaca-Sheering
#write code
$ git flow feature finish alpaca-Sheering
$ git flow feature resume yak-Speedup

Indeed, the existence of the "git flow feature list" command implies that I can have several features going at the same time. But I don't see how to create or switch between features. Indeed, I'm starting to think that this isn't a git flow issue at all, but a git issue.

事实上,“git flow feature list”命令的存在意味着我可以同时拥有多个功能。但我不知道如何在功能之间创建或切换。事实上,我开始认为这根本不是 git flow 问题,而是 git 问题。

I appreciate any help. Thanks!

我很感激任何帮助。谢谢!

回答by Dan Cruz

You do not need the git flow feature pause yak-Speedupcommand (feature pausedoesn't exist anyway). The command you want to use in place of git flow feature resume yak-Speedupis git flow feature checkout yak-Speedup; that will get you back on the yak-Speedupfeature branch to continue development.

您不需要该git flow feature pause yak-Speedup命令(feature pause无论如何都不存在)。您要代替的命令git flow feature resume yak-Speedupgit flow feature checkout yak-Speedup; 这将使您回到yak-Speedup功能分支以继续开发。

Executing git flowdisplays:

执行git flow显示:

Try 'git flow <subcommand> help' for details.

And executing git flow feature helpdisplays:

并执行git flow feature help显示:

usage: git flow feature [list] [-v]
       git flow feature start [-F] <name> [<base>]
       git flow feature finish [-rFk] <name|nameprefix>
       git flow feature publish <name>
       git flow feature track <name>
       git flow feature diff [<name|nameprefix>]
       git flow feature rebase [-i] [<name|nameprefix>]
       git flow feature checkout [<name|nameprefix>]
       git flow feature pull <remote> [<name>]

回答by angryITguy

Late to the party, but my experience is this..I use git in combination with git flow..

聚会迟到了,但我的经验是这样的..我将 git 与 git flow 结合使用..

git flow feature start foo  <<== start
#code, hack and COMMIT
git checkout develop        <<== go back to develop branch.. 
git flow feature start foo2 <<== start a new feature
#code, hack and COMMIT
git checkout feature/foo    <<== go back to foo. NB: using full branch name

By going back to develop i ensure that I am branching independently from foo and using develop only. I can also do any merging of develop if there has been commits from other features at the time as well....

通过返回开发,我确保我独立于 foo 分支并仅使用开发。如果当时其他功能也有提交,我也可以对开发进行任何合并......

回答by fge

What you want are really branches:

你想要的是真正的分支:

git branch feature1 <startingpoint>
git checkout feature1
# hack hack hack, commit commit commit
git branch feature2 <startingpoint>
git checkout feature2
# hack hack hack, commit commit commit
# Oops, urgent request comming in, must switch to stable and patch
git stash
git checkout stable
# patch, commit, push
# back to feature2
git checkout feature2
git stash pop

etc etc. Branches are made for that.

等等等等。分支是为此而制作的。

And once you know your feature is good, merge into dev and push.

一旦你知道你的特性很好,就合并到 dev 和 push 中。

回答by Adam Dymitruk

Use a more explicit model. This is git flow improved with no extra commands:

使用更明确的模型。这是 git flow 改进的,没有额外的命令:

https://plus.google.com/109096274754593704906/posts/R4qkeyRadLR

https://plus.google.com/109096274754593704906/posts/R4qkeyRadLR

The important thing here is that you would not start feature2 off of feature1.

这里重要的是您不会从功能 1 开始功能 2。

Hope this helps.

希望这可以帮助。

UPDATE

更新

I've blogged about this. Hope it's a little clearer:

我已经写了关于这个的博客。希望它更清楚一点:

http://dymitruk.com/blog/2012/02/05/branch-per-feature/

http://dymitruk.com/blog/2012/02/05/branch-per-feature/