git 尝试推送 SourceTree 时,“更新被拒绝,因为标签已经存在”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31929667/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Updates were rejected because the tag already exists" when attempting to push in SourceTree
提问by Senseful
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?
据我所知,我没有对此标签进行任何更改。我怎样才能解决这个问题?
回答by bytedev
You should also be able to solve this in git bash (click on "Terminal" button in the Source Tree UI). Type:
您还应该能够在 git bash 中解决此问题(单击源树 UI 中的“终端”按钮)。类型:
git pull --tags
回答by Senseful
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):
如果您尚未对要保留的标签进行任何本地更改,那么您可以删除因已存在而被拒绝的标签(example_tag
在本例中):
- Right-click the tag and choose to delete it (be sure to uncheckthe Remove tag from all remotescheckbox).
- Choose the Fetchoption (Fetch and store all tags locally does nothave to be enabled).
- You should now have that tag that was just deleted back, and attempting to Pushwill no longer show that error message.
- 右键单击该标签,然后选择删除它(一定要取消对所有遥控器删除标签复选框)。
- 选择获取选项(获取并存储所有标签本地并没有必须启用)。
- 您现在应该拥有刚刚删除的标签,并且尝试推送将不再显示该错误消息。
The reason this is common in SourceTree is because the Push all tagsoption is set to onby default. (Another way to hide this error is to uncheck that option.)
这在 SourceTree 中很常见的原因是因为Push all tags选项默认设置为on。(另一种隐藏此错误的方法是取消选中该选项。)
回答by JDev-Guns
Uncheck push all tags
at the bottom of the UI when you confirm your git push
push all tags
确认 git push 时取消选中UI 底部
回答by Ogglas
git pull --tags
works really well but sometimes you can get an error even with this command. Example error message:
git pull --tags
效果非常好,但有时即使使用此命令也会出错。示例错误消息:
! [rejected] example_tag -> example_tag (would clobber existing tag)
This can be solved with the command: git pull --tags -f
这可以通过以下命令解决: git pull --tags -f
Source:
来源:
回答by Sudheer Kumar Palchuri
回答by YoungJeXu
Yes, indeed, pull the tags first before you push --tags
. Solved my problem.
是的,确实,在你之前先拉标签push --tags
。解决了我的问题。
回答by Marco Barbero
I resolve the problem on SourceTreein this way:
我以这种方式解决了SourceTree上的问题:
- Deleting the tag with the selection "Remove the tag from all remotes"
- Recreating the tag
- 通过选择“从所有遥控器中删除标签”删除标签
- 重新创建标签