使用 GIT Flow 完成功能分支

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

Finishing a feature branch with GIT Flow

gitversion-controlgit-flowatlassian-sourcetree

提问by Lea Hayes

From my understanding one of the advantages of creating feature branches is so that you can easily see where large groups of commits have been merged into the develop branch.

根据我的理解,创建功能分支的优势之一是您可以轻松查看大量提交已合并到开发分支的位置。

Upon finishing a feature branch the recommendation is to delete the feature branch since it is no longer needed for development. Once the branch has been deleted, will the graph still be annotated with "feature/my-fancy-feature" branched and merged?

完成功能分支后,建议删除该功能分支,因为开发不再需要它。删除分支后,图形是否仍会标注“功能/我的花式功能”分支和合并?

回答by melvynkim

"Upon finishing a feature branch the recommendation is to delete the feature branch since it is no longer needed for development."

“完成功能分支后,建议删除该功能分支,因为开发不再需要它。”

Difference between "discarding" and "merging" the feature branch:

“丢弃”和“合并”功能分支的区别:

"Finishing" is an ambiguous expression here. To make sure I fully cover your question, I believe you meant either one of the following cases:

“完成”在这里是一个模棱两可的表达。为了确保我完全涵盖您的问题,我相信您的意思是以下任一情况:

(1) If you wish to discardthe feature/my-fancy-feature:

(1)如果你想放弃feature/my-fancy-feature

git branch -d feature/my-fancy-feature

(2) If you meant to mergethe feature/my-fancy-feature:

(2)如果你的意思是合并feature/my-fancy-feature

git flow feature finish my-fancy-feature


"Once the branch has been deleted, will the graph still be annotated with "feature/my-fancy-feature" branched and merged?"

“一旦分支被删除,图形是否仍会被标注为“功能/我的花式功能”分支和合并?”

Difference between "fast-forward-merge" and "non-fast-forward-merge"

“快进合并”和“非快进合并”的区别

It depends (the outcome is not git-flowdependent). git logwon't give you the specific branch name (e.g. feature/my-fancy-feature). It will only give you the commit history with the message. Recalling the differences between fast-forwardmerging and non-fast-forwardmerging:

这取决于(结果不git-flow相关)。git log不会给你具体的分支名称(例如feature/my-fancy-feature)。它只会为您提供带有消息的提交历史记录。回顾快进合并和非快进合并的区别:

fast-forward-merge(all commit history made in feature/my-fancy-featurewill remain):

快进合并(所有提交历史feature/my-fancy-feature将保留):

git merge

non-fast-forward-merge(all commit history made in feature/my-fancy-featurewill be gone):

非快进合并(所有提交历史都feature/my-fancy-feature将消失):

git merge --no-ff

Refere to the following illustration from Vincent Driessen's article:

请参阅 Vincent Driessen文章中的以下插图:

enter image description here

在此处输入图片说明

Update

更新

To enable non-fast-forwardfeature in SourceTree, checkthe below global preference option found from Menubar-> SourceTree -> Preferences -> Git:

要在 SourceTree 中启用非快进功能,请检查以下全局首选项Menubar-> SourceTree -> Preferences -> Git

enter image description here

在此处输入图片说明

For further explanation, I found this excerpt from SourceTree's "Help Center":

为了进一步解释,我从 SourceTree 的“帮助中心”找到了这段摘录:

disables fast-forward behaviour when merging, meaning that an explicit merge commit is always created regardless of whether there are other changes in the receiving branch. This can be useful if you want to maintain an explicitly separate line of development in all cases.

合并时禁用快进行为,这意味着无论接收分支中是否有其他更改,始终会创建显式合并提交。如果您想在所有情况下都保持明确独立的开发线,这会很有用。

Hope it helped!

希望有帮助!

回答by meagar

No, only the commit messages will remain; if you want to retain the name of the branch, be sure to include it in the merge commit or explicitly tag the merge commit with a related name.

不,只有提交消息会保留;如果要保留分支的名称,请确保将其包含在合并提交中或使用相关名称显式标记合并提交。

Your best bet is to stop worrying about retaining this data outside of the commit messages; by the time you merge your feature branch, you shouldn't care that the work was done on a feature branch.

最好的办法是不要担心在提交消息之外保留这些数据;当您合并功能分支时,您不应该关心工作是否在功能分支上完成。