21

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?

Lea Hayes
  • 62,536
  • 16
  • 62
  • 111

2 Answers2

23

"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:

enter image description here

Update

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

enter image description here

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!

melvynkim
  • 1,655
  • 3
  • 25
  • 38
  • In SourceTree I selected "Finish Feature" which I believe would be the equivalent of `git flow feature finish my-fancy-feature`. The GUI doesn't appear to provide an option for specifying --no-ff. But, with that said I believe that the commit history is a lot more important than seeing which branches commits came from. I was initially under the impression that one of the advantages of using feature branches was that you *could* see the graph even after finishing with the feature. – Lea Hayes May 06 '13 at 18:48
  • 1
    @LeaHayes SourceTree *does* support `--no-ff`. Please refer to my updated answer above. The graph will remain if you **uncheck** `--no-ff` option as described in my updated answer (it's unchecked by default). – melvynkim May 07 '13 at 02:02
  • I guess that this must be a limitation with the Windows version of SourceTree. **Git Flow: Finish Feature:** http://pbrd.co/18rHnsS **Merge:** http://pbrd.co/18rHuF2 It looks like they have added the opposite option for "Merge", but it doesn't look like this is part of Git Flow. – Lea Hayes May 07 '13 at 15:35
  • git does like "discarding" with `git branch -d feature/my-fancy-feature`. It will insist you use capital D if the branch hasn't been merged into anything. `git branch -D feature/my-fancy-feature` ... do I get a cookie or something? – anregen Jul 08 '14 at 15:23
  • I'd point out a potential gotcha that exists with SourceTree, if not other Git Flow clients...Feature branches with two or more commits to them will appear as per your graph on the left (git merge --no-ff), but a feature branch with just a single commit to it will appear as per your graph on the right (git merge plain). This is extremely annoying will looking in the history, especially when trying to search by feature branch name. – AlwaysLearning Oct 24 '16 at 01:30
4

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.

user229044
  • 232,980
  • 40
  • 330
  • 338
  • I went with the default option which seems to have preserved the graph despite the fact the feature branch no longer exists. Obviously the name of the branch has been removed, but the visual representation is still there. I am happy with this since the commits are logically grouped. And like you said, I could explicitly tag the merge commit. Would I use a lightweight tag for this? – Lea Hayes May 07 '13 at 19:12