192

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://user@github.com/repo.git
To https://user@github.com/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://user@github.com/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?

Senseful
  • 86,719
  • 67
  • 308
  • 465

6 Answers6

358

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
Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
bytedev
  • 8,252
  • 4
  • 48
  • 56
140

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.)

Senseful
  • 86,719
  • 67
  • 308
  • 465
  • "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. – Tom Oct 06 '16 at 23:33
  • Assuming the upstream (origin) repo is the source of truth, this solution is the least destructive, and fixes the problem instantly. – Steve Henty Apr 05 '18 at 21:38
  • 1
    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. – aaa Dec 17 '19 at 09:51
  • "Right-click" where? What type o IDE are you assuming? – ricoms Mar 26 '21 at 18:50
  • `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 – samthui7 Feb 17 '22 at 08:19
52

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

Volker E.
  • 5,911
  • 11
  • 47
  • 64
Ogglas
  • 62,132
  • 37
  • 328
  • 418
37

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

Andreas Kraft
  • 3,754
  • 1
  • 30
  • 39
JDev-Guns
  • 379
  • 3
  • 3
28

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

enter image description here

Sudheer Kumar Palchuri
  • 2,919
  • 1
  • 28
  • 38
  • As mentioned above, if you added a new tag locally doesn't this mean it isn't pushed to the remote? – bytedev Mar 27 '20 at 02:49
3

In SourceTree, this seems to work:

  1. Click the Fetch icon
  2. Check "Fetch all tags"
  3. Click Ok
John Berg
  • 105
  • 6