"Updates were rejected because the tag already exists" when attempting to push in SourceTree
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):
- Right-click the tag and choose to delete it (be sure to uncheck the Remove tag from all remotes checkbox).
- Choose the Fetch option (Fetch and store all tags locally does not have to be enabled).
- 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.
Related videos on Youtube
Senseful
Updated on January 19, 2022Comments
-
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 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 about 6 yearsAssuming the upstream (origin) repo is the source of truth, this solution is the least destructive, and fixes the problem instantly.
-
Chad about 6 yearsI feel this is the best answer for it's the path of least resistance.
-
Wodin over 5 yearsDid you mean
push all tags
? -
Meg-90 over 5 yearsGreat! Did not observe it. Thanks
-
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 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 meantTAGs
instead ofTABs
. -
JDev-Guns over 5 years@Wodin oh gotcha! i think i said
TAGs
but if i didnt, i meant to sayTABs
-
DenLilleMand about 5 yearsWith a conflict you can do
git pull --tags -f
to overwrite the one you have locally if that's what you want -
iPhoneDeveloper almost 5 yearsThis really helped. Thanks.
-
Darkgaze over 4 yearsIn SourceTree, click Fetch, and enable "fetch all tags". That would do it.
-
SagiSergeNadir over 4 yearsUnfortunately 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 over 4 yearsBut if you added a new tag locally doesn't this mean it isn't pushed to the remote?
-
bytedev about 4 yearsAs mentioned above, if you added a new tag locally doesn't this mean it isn't pushed to the remote?
-
Fred Zimmerman about 3 years@DenLilleMand's comment should be the accepted answer.
-
Ricardo M S about 3 years"Right-click" where? What type o IDE are you assuming?
-
Gil Grencho over 2 yearsImo, this is the best response.
-
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