Every time I try to update a particular repository, it fails because the maintainer regularly changes the nightly tag:
$ git fetch
From https://github.com/kyazdani42/nvim-tree.lua
! [rejected] nightly -> nightly (would clobber existing tag)
I added remote.origin.tagOpt = --no-tags to the .git/config. The setting is apparently useless because it fetches the tags regardless.
I also tried remote.origin.prune = true and remote.origin.pruneTags = true which made no difference.
Here's the full config:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://github.com/kyazdani42/nvim-tree.lua.git
fetch = +refs/heads/*:refs/remotes/origin/*
prune = true
pruneTags = true
tagOpt = --no-tags
[branch "master"]
remote = origin
merge = refs/heads/master
Here's the relevant part of man git-fetch:
By default, any tag that points into the histories being fetched is also fetched; the effect is to fetch tags that point at branches that you are interested in. This default behavior can be changed by using the --tags or --no-tags options or by configuring remote.<name>.tagOpt. By using a refspec that fetches tags explicitly, you can fetch tags that do not point into branches you are interested in as well.
Is this a git bug or am I doing something wrong?
Edit: I discovered a workaround:
[remote "origin"]
url = https://github.com/kyazdani42/nvim-tree.lua.git
fetch = +refs/heads/*:refs/remotes/origin/*
fetch = ^refs/tags/*
tagOpt = --no-tags
I'm still wondering if there's a better way though.
I'm not convinced that Git's tag handling always works as claimed in the documentation, and, even with as deep as I've gotten into Git, I'm not always sure what the documentation even intends to claim in the first place. Still, it seems to me that --no-tags here should have worked for you. So I think this is a Git bug—but it's not clearly, definitively a bug: maybe it's supposed to do what it is doing.
That said, what will work for you is to tell git fetch to forcibly update refs/tags/nightly automatically:
[remote "origin"]
url = https://github.com/kyazdani42/nvim-tree.lua.git
fetch = +refs/heads/*:refs/remotes/origin/*
fetch = +refs/tags/nightly:refs/tags/nightly
This will make your Git willing to force-update the nightly tag, so that you won't need --no-tags to behave.
Obviously your workaround also works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With