Finishing a feature branch with GIT Flow

2020-02-08 07:46发布

问题:

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?

回答1:

"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 discard the feature/my-fancy-feature:

git branch -d feature/my-fancy-feature

(2) If you meant to merge the 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-flow dependent). git log won'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-forward merging and non-fast-forward merging:

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

git merge

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

git merge --no-ff

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

Update

To enable non-fast-forward feature in SourceTree, check the below global preference option found from Menubar-> SourceTree -> Preferences -> Git:

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

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!



回答2:

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.