当尝试推送SourceTree时,"更新被拒绝,因为标签已经存在"

Sen*_*ful 93 git push atlassian-sourcetree

尝试通过源树推送时,我收到以下错误:

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
Run Code Online (Sandbox Code Playgroud)

据我所知,我没有对这个标签做任何改动.我怎样才能解决这个问题?

byt*_*dev 184

您还应该能够在git bash中解决此问题(单击Source Tree UI中的"Terminal"按钮).类型:

git pull --tags
Run Code Online (Sandbox Code Playgroud)

  • 如果发生冲突,您可以执行git pull --tags -f来覆盖您本地拥有的那个 (12认同)
  • 在 SourceTree 中,单击“获取”,然后启用“获取所有标签”。这样就可以了。 (4认同)
  • 我觉得这是最好的答案,因为它是阻力最小的道路. (3认同)
  • 这应该是公认的答案.您不想删除生产标签 (2认同)

Sen*_*ful 107

如果您没有对要保留的标记进行任何本地更改,则可以删除因已存在而被拒绝的标记(example_tag在本例中):

  1. 右键单击标记并选择将其删除(确保取消选中 " 从所有远程复制删除标记"复选框).
  2. 选择获取选项(获取并存储所有标签本地并没有必须启用).
  3. 您现在应该已经删除了刚删除的标记,并且尝试Push将不再显示该错误消息.

这在SourceTree中很常见的原因是因为默认情况下Push all tags选项设置为on.(隐藏此错误的另一种方法是取消选中该选项.)


小智 22

push all tags当您确认git push时,取消选中UI底部


Sud*_*uri 8

确保在推送时取消选中“推送所有标签”按钮。

在此处输入图片说明


Ogg*_*las 8

git pull --tags效果很好,但有时即使使用此命令也会出现错误。错误消息示例:

 ! [rejected]        example_tag      -> example_tag  (would clobber existing tag)
Run Code Online (Sandbox Code Playgroud)

这可以通过以下命令解决: git pull --tags -f

资源:

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

  • 谢谢你!这就是解决我的问题的方法 (2认同)