"Updates were rejected because the tag already exists" when attempting to push in SourceTree

98,629

Solution 1

If you have not made any local changes to the tag that you want to keep, then you can remove tag that was rejected because it already exists (example_tag in this case):

  1. Right-click the tag and choose to delete it (be sure to uncheck the Remove tag from all remotes checkbox).
  2. Choose the Fetch option (Fetch and store all tags locally does not have to be enabled).
  3. You should now have that tag that was just deleted back, and attempting to Push will no longer show that error message.

The reason this is common in SourceTree is because the Push all tags option is set to on by default. (Another way to hide this error is to uncheck that option.)

Solution 2

You should also be able to solve this in git bash (click on "Terminal" button in the Source Tree UI). Type:

git pull --tags

If you have conflicting tags, you can include the -f option in the command to override the local conflicting tags with their remote versions.

git pull --tags -f

Solution 3

git pull --tags works really well but sometimes you can get an error even with this command. Example error message:

 ! [rejected]        example_tag      -> example_tag  (would clobber existing tag)

This can be solved with the command: git pull --tags -f

-f stands for force.

Source:

https://github.com/concourse/git-resource/issues/233

Solution 4

Uncheck push all tags at the bottom of the UI when you confirm your git push

Solution 5

Make sure you uncheck the "Push all tags" button while push.

enter image description here

Share:
98,629

Related videos on Youtube

Senseful
Author by

Senseful

Updated on January 19, 2022

Comments

  • Senseful
    Senseful over 2 years

    When attempting to Push via Source Tree, I get the following error:

    git -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags origin refs/heads/master:refs/heads/master 
    Pushing to https://[email protected]/repo.git
    To https://[email protected]/repo.git
     = [up to date]      master -> master
    ...
     ! [rejected]        example_tag -> example_tag (already exists)
    updating local tracking ref 'refs/remotes/origin/master'
    error: failed to push some refs to 'https://[email protected]/repo.git'
    hint: Updates were rejected because the tag already exists in the remote.
    Completed with errors, see above
    

    I didn't make any changes to this tag as far as I know. How can I fix this?

  • Tom
    Tom over 7 years
    "Fetch and store all tags locally does not have to be enabled" is what did it for me, checking that just caused the problem to repeat itself.
  • Steve Henty
    Steve Henty about 6 years
    Assuming the upstream (origin) repo is the source of truth, this solution is the least destructive, and fixes the problem instantly.
  • Chad
    Chad about 6 years
    I feel this is the best answer for it's the path of least resistance.
  • Wodin
    Wodin over 5 years
    Did you mean push all tags?
  • Meg-90
    Meg-90 over 5 years
    Great! Did not observe it. Thanks
  • JDev-Guns
    JDev-Guns over 5 years
    @Wodin so if you CHECK the push all tags in the UI it will try to overwrite the previous tags. but you have to UNCHECK it to prevent the overwrite
  • Wodin
    Wodin over 5 years
    @JDev-Guns I was just querying the wording. You originally said push all TABs. I am not familiar with SourceTree, but I suspected you meant TAGs instead of TABs.
  • JDev-Guns
    JDev-Guns over 5 years
    @Wodin oh gotcha! i think i said TAGs but if i didnt, i meant to say TABs
  • DenLilleMand
    DenLilleMand about 5 years
    With a conflict you can do git pull --tags -f to overwrite the one you have locally if that's what you want
  • iPhoneDeveloper
    iPhoneDeveloper almost 5 years
    This really helped. Thanks.
  • Darkgaze
    Darkgaze over 4 years
    In SourceTree, click Fetch, and enable "fetch all tags". That would do it.
  • SagiSergeNadir
    SagiSergeNadir over 4 years
    Unfortunately when you have 15 rejected tags the 1,2, and 3 steps can be very tedious. Yes, disabling the "Push all tags" option is a probably the right way to go.
  • bytedev
    bytedev over 4 years
    But if you added a new tag locally doesn't this mean it isn't pushed to the remote?
  • bytedev
    bytedev about 4 years
    As mentioned above, if you added a new tag locally doesn't this mean it isn't pushed to the remote?
  • Fred Zimmerman
    Fred Zimmerman about 3 years
    @DenLilleMand's comment should be the accepted answer.
  • Ricardo M S
    Ricardo M S about 3 years
    "Right-click" where? What type o IDE are you assuming?
  • Gil Grencho
    Gil Grencho over 2 years
    Imo, this is the best response.
  • samthui7
    samthui7 about 2 years
    The reason this is common in SourceTree is because the Push all tags option is set to on by default. (Another way to hide this error is to uncheck that option.) is exactly what I need