Skip to content

Commit 77c7278

Browse files
committed
Documentation: merging a tag is a special case
When asking Git to merge a tag (such as a signed tag or annotated tag), it will always create a merge commit even if fast-forward was possible. It's like having --no-ff present on the command line. It's a difference from the default behavior described in git-merge.txt. It should be documented as an exception of "FAST-FORWARD MERGE" section and "--ff" option description. Reviewed-by: Jonathan Nieder <[email protected]> Reviewed-by: Yann Droneaud <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5d41784 commit 77c7278

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Documentation/git-merge.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,30 @@ happens:
170170
If you tried a merge which resulted in complex conflicts and
171171
want to start over, you can recover with `git merge --abort`.
172172

173+
MERGING TAG
174+
-----------
175+
176+
When merging an annotated (and possibly signed) tag, Git always
177+
creates a merge commit even if a fast-forward merge is possible, and
178+
the commit message template is prepared with the tag message.
179+
Additionally, if the tag is signed, the signature check is reported
180+
as a comment in the message template. See also linkgit:git-tag[1].
181+
182+
When you want to just integrate with the work leading to the commit
183+
that happens to be tagged, e.g. synchronizing with an upstream
184+
release point, you may not want to make an unnecessary merge commit.
185+
186+
In such a case, you can "unwrap" the tag yourself before feeding it
187+
to `git merge`, or pass `--ff-only` when you do not have any work on
188+
your own. e.g.
189+
190+
---
191+
git fetch origin
192+
git merge v1.2.3^0
193+
git merge --ff-only v1.2.3
194+
---
195+
196+
173197
HOW CONFLICTS ARE PRESENTED
174198
---------------------------
175199

Documentation/merge-options.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ set to `no` at the beginning of them.
3030

3131
--no-ff::
3232
Create a merge commit even when the merge resolves as a
33-
fast-forward.
33+
fast-forward. This is the default behaviour when merging an
34+
annotated (and possibly signed) tag.
3435

3536
--ff-only::
3637
Refuse to merge and exit with a non-zero status unless the

0 commit comments

Comments
 (0)