小编典典

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

all

尝试通过源树推送时,出现以下错误:

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

据我所知,我没有对此标签进行任何更改。我怎样才能解决这个问题?


阅读 113

收藏
2022-08-27

共1个答案

小编典典

如果您没有对要保留的标签进行任何本地更改,那么您可以 删除因为 已经存在 而被拒绝的标签(example_tag在这种情况下):

  1. 右键单击标签并选择删除它(确保 取消选中 从所有遥控器 中删除标签复选框)。
  2. 选择 获取选项( 不必 启用在本地获取和存储所有标签)。
  3. 您现在应该拥有刚刚删除的标签,并且尝试 推送 将不再显示该错误消息。

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

2022-08-27