尝试通过源树推送时,出现以下错误:
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
据我所知,我没有对此标签进行任何更改。我该如何解决这个问题?
您还应该能够在 git bash 中解决这个问题(单击源树 UI 中的“终端”按钮)。类型:
git pull --tags
如果您有冲突的标签,您可以在命令中包含
-f
选项,以使用远程版本覆盖本地冲突标签。
git pull --tags -f
如果您尚未对要保留的标签进行任何本地更改,则可以删除被拒绝的标签,因为它已经存在(在本例中为
example_tag
):
这在 SourceTree 中很常见的原因是因为 Push all Tags 选项默认设置为 on。 (隐藏此错误的另一种方法是取消选中该选项。)
git pull --tags
效果非常好,但有时即使使用此命令也会出现错误。错误消息示例:
! [rejected] example_tag -> example_tag (would clobber existing tag)
这可以通过命令解决:
git pull --tags -f
-f
代表力。
来源:
确认 git 推送时,取消选中 UI 底部的
push all tags
在 SourceTree 中,这似乎有效: