51

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

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

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

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

$ git flow feature start yak-Speedup

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

我想做这样的事情:

$ 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

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

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

4

4 回答 4

50

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

执行git flow显示:

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

并执行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>]
于 2011-12-21T18:07:40.257 回答
8

聚会迟到了,但我的经验是……我将 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

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

于 2016-08-13T08:16:23.763 回答
0

你想要的是真正的分支:

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

等等等等。为此设立了分支机构。

一旦你知道你的功能很好,就合并到开发中并推送。

于 2011-12-20T20:37:33.973 回答
0

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

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

这里重要的是你不会从 feature1 开始 feature2。

希望这可以帮助。

更新

我在博客上写过这个。希望它更清楚一点:

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

于 2011-12-20T20:45:10.150 回答