Reputation: 41
I have two projects (A and B) both with "master" and "devel" branches. In project A, I merged "devel" with "master" (git also asked me to add a merge message) and then tagged the last commit as "v1.0" on master branch. When I issued "git show v1.0" on master branch of project A, the output was simplistic as:
tag v1.0
Tagger: Ekin Akoglu <[email protected]>
Date: Tue Mar 3 17:33:52 2015 +0100
Version 1.0 - Rozana
commit 3bede2111540b0b57ae994e3a16a98203c07c02e
Merge: 179d4b1 cd3337a
Author: Ekin Akoglu <[email protected]>
Date: Tue Mar 3 17:01:35 2015 +0100
Merge branch 'Tampa_Bay'
Implementation of EwE 6.5 modifications. Updated testcase files.
In project B, I also merged "devel" with "master" (git did not ask me to add a merge message). But then, while on "devel" branch, I erroneously tagged the last commit as "v1.0". Then I deleted this tag and switched to "master" branch of project B and tagged the last commit as "v1.0". Then, I issued "git show v1.0", and the output was
tag v1.0
Tagger: Ekin Akoglu <[email protected]>
Date: Tue Mar 3 19:37:07 2015 +0100
version 1.0 - Rozana
commit 0835d7
Author: Ekin Akoglu <[email protected]>
Date: Tue Mar 3 16:57:03 2015 +0100
Implemented EwE 6.5 modifications. Updated test case files
and respective comparative scripts. Removed mosca0D test cases.
plus a lot of git-diff output appended at the end of the above message. Could anyone please tell me what the difference is between the two projects so that project B shows the git-diff output appended to the end of the tag message summary and project A does not?
Thank you.
Upvotes: 1
Views: 212
Reputation: 4626
In Project A, tag v1.0 is on a merge commit. Git asked you for a merge message likely because fast-forward was not possible. This happens any time the tip of the destination branch is not in the direct history of the branching you are merging. You can see this easily in a graphical history viewer, or simply by looking at the line Merge: 179d4b1 cd3337a
in your output above.
In project B, your merge was a fast-forward because there had been no changes on master
(i.e. it was in the direct history of develop
). Thus your v1.0 tag is on a normal commit.
This difference matters if you use git show
, because git show
will always display the diff introduced by the referenced commit. In project A there is no diff if your merge didn't introduce any modifications (i.e. no added content modified during the merge, no conflicts solved...). In project B, you see a diff because the tagged commit is a "normal" one.
What you could have done at the time of merging was force a merge commit with --no-ff
:
git checkout master
git merge develop --no-ff
This would produce an equivalent output of git show
as for project A. Enforcing merge-commits is a good habit because the merge commit message will contain a list of all commit message included in the merge (see Git Flow for example).
Upvotes: 1