In the documentation for git’s merge command, the result of git merge topic is shown as this:
A---B---C topic
/ \
D---E---F---G---H master
In this scenario it looks to me that if I were to delete topic to keep my branch list tidy, that all record of commits A, B, and C would be lost, leaving only a single commit, H (and presumably deleting all the commit messages from A, B, and C):
D---E---F---G---H master
Would this indeed be the case, and if so how would I prevent it? E.g:
D---E---F---G---A---B---C master
No. Everything would still be there.
Before deleting topic branch:
A---B---C topic / \ D---E---F---G---H masterAfter deleting topic branch:
A---B---C / \ D---E---F---G---H masterThe branch is just a pointer to commit C. Deleting it doesn’t get rid of the commit.
Note that if you haven’t merged the topic branch yet, then deleting it will fail unless you use
git branch -D. Thegit branch -dcommand will only delete merged branches, which preserves all the history but gets rid of the branch name.Footnote: You can get the following history by using
git rebase masterfrom the topic branch, and then fast-forwarding master to topic, and deleting topic.Note that while this is possible it is probably not desirable — the original commits A, B, and C are lost by rebasing.