How to get rid of "would clobber existing tag"

Git

Git Problem Overview


I'm using git in VSCodium and each time I try to pull git is complaining.

Looking into the log I see

> git pull --tags origin master
From https://github.com/MY/REPO
 * branch            master     -> FETCH_HEAD
 ! [rejected]        latest     -> latest  (would clobber existing tag)
   9428765..935da94  master     -> origin/master

Doing the command with --force helps until the next time.

It's unclear to me what's going wrong here. What happened and how can I resolve this issue?

I mean: Besides trashing my local repo and cloning again.

Git Solutions


Solution 1 - Git

You should update your local tags with remote tags:

git fetch --tags -f

Then pull again.

Solution 2 - Git

Since you say it's unclear what's going wrong, I assume you're not using that tag for anything and you just want to do your own work.

Turn off this setting:

enter image description here

Or add this "git.pullTags": false in the settings.json file`

Now you're all set.


Detailed explanation:

Tags are just references to specific commits (just like branch names). The main difference is that git (as far as I know) assumes tags will not change, where branches are expected to be updated.

So, the "error" is that you have in your local a tag called latest pointing to commit X - but the remote has a tag called latest pointing to commit Y. If you apply the change from the remote you will overwrite your local tag.

VSCode will pull all tags by default, thus you get the error.

There isn't anything wrong with having a "moving" tag like latest, that just isn't something VSCode takes into account (personal opinion).


Alternatively, you can avoid the issue by using the command line and manually entering the git pull command. Specifically, you need to omit --tags to skip this step of the process.

If you do this, your tags will not be updated - but I don't think is a concern here.

Solution 3 - Git

The reason may be that you or other contributors deleted an original tag and recreated the same tag.

The solution:

git fetch --tags -f

Forced to refresh the local tag


When using the button to update the code in the editor, the default will first use git pull --tags origin master

Therefore, you can add this "git.pullTags": false in the configuration file settings.json of the Vscode

Solution 4 - Git

Edit: To be clear, the original question was related to a git issue. While it may not be obvious, yarn can also have git dependencies. So for the 0.1% of users that has this error while running yarn install, this is for you! If not, just use the accepted/top answers.


I got this error for a package while trying to run yarn install. The accepted answer was for the current repo and didn't work for me, but this worked:

rm -rf **/node_modules && yarn cache clean

I'd tried just removing node_modules before, guess cleaning yarn cache was what did it.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSkeeveView Question on Stackoverflow
Solution 1 - GitTuan TranView Answer on Stackoverflow
Solution 2 - GitVlad274View Answer on Stackoverflow
Solution 3 - GitzhuziyiView Answer on Stackoverflow
Solution 4 - GiteckcView Answer on Stackoverflow