用于修复错误的 Git 流分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11202069/
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
Git flow branching for fixing a bug
提问by kriysna
I have been using git flow for a while. I was searching for branching model for fixing issues and bugs found in the develop branch. I know we could use hotfix but it is for master branch, or quick bug fixes for the production.
我一直在使用 git flow 一段时间。我正在寻找用于修复在开发分支中发现的问题和错误的分支模型。我知道我们可以使用修补程序,但它用于主分支,或用于生产的快速错误修复。
Fixing a bug on development is not a feature. I could always reinitialize git flow and overwrite the default prefix branch to bug/. But it needed to reinitialize if I need to start new feature too. Is this a good practice or there is some technique to handle this?
修复开发中的错误不是一项功能。我总是可以重新初始化 git flow 并将默认前缀分支覆盖到 bug/。但是如果我也需要启动新功能,它需要重新初始化。这是一个很好的做法还是有一些技术可以解决这个问题?
采纳答案by wired00
git-flow-avh
is what you want
git-flow-avh
是你想要的
For osx:
对于 osx:
brew uninstall git-flow #remove your current
brew install git-flow-avh #add the update
brew uninstall git-flow #remove your current
brew install git-flow-avh #add the update
Within project folder:
在项目文件夹中:
git init
- you should see amongst prompts -
Bugfix branches? [bugfix/]
which would not have been a prompt with standardgit-flow
- start a new bugfix -
git flow bugfix start <branch name>
git init
- 你应该在提示中看到 -
Bugfix branches? [bugfix/]
这不会是标准的提示git-flow
- 开始一个新的错误修正 -
git flow bugfix start <branch name>
回答by Peter van der Does
If the fix you need to apply is just a one commit fix I would just do it in develop without creating a branch, if it involves multiple commits you just use the git flow feature
command. The software currently will do a git merge -ff
when you finish a feature branch with only one commit, which in your logs will look the same as just a commit on develop.
如果您需要应用的修复只是一个提交修复,我会在开发中完成而不创建分支,如果它涉及多个提交,您只需使用该git flow feature
命令。该软件目前将git merge -ff
在您仅通过一次提交完成功能分支时执行一次,这在您的日志中看起来与开发时的提交相同。
If you would like to indicate in your log that this feature would be a bugfix you could just name the branch something like "bugfix-missing-parameter" or "issue-34-not-reading-file-properly"
如果您想在日志中指出此功能将是一个错误修复,您可以将分支命名为“bugfix-missing-parameter”或“issue-34-not-reading-file-properly”
I can see how the word feature could imply "something new" instead of "fixing" but that's just words. Should I create a new command for a fix, the code would look exactly the same as the code of git flow feature
so I don't see any benefit in that.
我可以看到功能这个词如何暗示“新事物”而不是“修复”,但这只是词。如果我为修复创建一个新命令,代码看起来与 的代码完全相同,git flow feature
所以我看不到任何好处。
Update November 19, 2015
2015 年 11 月 19 日更新
Since Version 1.9.0 the gitflow AVH Edition has a bugfix command. It's the same thing as feature but the branch is prefix with bugfix instead of feature.
从 1.9.0 版开始,gitflow AVH 版有一个错误修复命令。它与功能相同,但分支的前缀是错误修复而不是功能。
回答by VonC
The idea of fixing a bug on the development
branch, as opposed to git flow hotfix
(on master
) is that:
development
与git flow hotfix
(on master
)相对,在分支上修复错误的想法是:
- you generally fix the bug on development
HEAD
(it is just another commit which fixes some issue introduced by other commits) - you do an hotfix on a specific version/tag of master ("
production
branch") in a dedicated branch, and you will or will not merge that hotfix back (if the hotfix is very specific to a certain version, and is no longer relevant in the subsequent releases, you won't merge it back at all)
- 您通常会修复开发中的错误
HEAD
(这只是另一个提交,它修复了其他提交引入的一些问题) - 您
production
在专用分支中对 master 的特定版本/标签(“分支”)进行修补程序,并且您将或不会将该修补程序合并回(如果修补程序非常特定于某个版本,并且不再与后续版本,您根本不会将其合并)
So I don't think you need a dedicated branch / "git flow
" operation: just make a well identified commit and push it on top of the development
branch.
所以我不认为你需要一个专门的分支/“ git flow
”操作:只需做出一个明确的提交并将其推送到development
分支的顶部。