Subject: Re: git-2.51.0: Fetching tags does not work

From: Junio C Hamano <[email-masked]>
Date: Fri, 05 Sep 2025 21:56:57 -0700

David Bohman <[email-masked]> writes:

> This is into a bare repository:
>
> git fetch --tags
>
> The command notates the tags it will update, but they do not get added
> to the repository.
>
> I reverted to git-2.50.1, and the problem went away. This is a
> regression in git-2.51.0.

The following is my attempt to reproduce ("rungit $version" is my
way to invoke any one of many versions of Git I have installed).

First let's create a bare clone of a repository "foo" in bar.git

: git x; rungit v2.51.0 clone --bare file://$(pwd)/foo bar.git
Cloning into bare repository 'bar.git'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (3/3), done.
: git x; cd bar.git
: git bar.git/BARE:master; rungit v2.51.0 for-each-ref
dcd3daa27e4c2f5182cfa80e5097fed4936b7037 commit refs/heads/master

So now I cloned from "foo" to obtain the "master" branch.  There is
no tag, so nothing else was transferred.

Then we go back to "foo", create a new commit, and a tag.

: git bar.git/BARE:master; cd ../foo
: git foo/master; date >stamp && rungit v2.51.0 commit -a -m "second"
HEAD is now at 2ec78a8 second
: git foo/master; rungit v2.51.0 tag really
: git foo/master; rungit v2.51.0 for-each-ref
2ec78a8e44a74213773a96f6c870b59ae2bfc7f0 commit refs/heads/master
2ec78a8e44a74213773a96f6c870b59ae2bfc7f0 commit refs/tags/really

Now we have an updated branch plus a tag.  We go back to the bare
repository that was created earlier by cloning "foo".

: git foo/master; cd ../bar.git
: git bar.git/BARE:master; rungit v2.51.0 fetch --dry-run
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Unpacking objects: 100% (3/3), 252 bytes | 63.00 KiB/s, done.
>From file:///var/tmp/x/foo
 * branch            HEAD       -> FETCH_HEAD

Without --tags, we would not fetch the tag.

: git bar.git/BARE:master; rungit v2.51.0 fetch --dry-run --tags
>From file:///var/tmp/x/foo
 * branch            HEAD       -> FETCH_HEAD
 * [new tag]         really     -> really

With --tags, we would.  After seeing these two dry-run results,
and making sure ...

: git bar.git/BARE:master; rungit v2.51.0 for-each-ref
dcd3daa27e4c2f5182cfa80e5097fed4936b7037 commit refs/heads/master

... dry-runs did not do anything, let's try a fetch for real.

: git bar.git/BARE:master; rungit v2.51.0 fetch --tags
>From file:///var/tmp/x/foo
 * branch            HEAD       -> FETCH_HEAD
 * [new tag]         really     -> really
: git bar.git/BARE:master; rungit v2.51.0 for-each-ref
dcd3daa27e4c2f5182cfa80e5097fed4936b7037 commit refs/heads/master
2ec78a8e44a74213773a96f6c870b59ae2bfc7f0 commit refs/tags/really

We have the tag fetched.  Note that this bare clone does not have
any fetch refspec,...

: git bar.git/BARE:master; cat config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = true
[remote "origin"]
        url = file:///var/tmp/x/foo

...so the master branch hasn't been updated (the new value is only
in FETCH_HEAD, which is expected).

As we can see here, my local copy of 2.51 does not seem to exhibit
such a problem, so you may need to narrow it down a bit more for
others to be able to help.

Thanks.