Git推送--set-upstream问题

4

分支refs/remotes/origin/feature/US12376被推送到origin,但在这之前它已经被推送了多次:

Your branch is based on 'origin/feature/US12376', but the upstream is gone.
  (use "git branch --unset-upstream" to fixup)

于是我使用了git branch --unset-upstream命令(执行成功)。

继续进行工作

提交(commit)后,我尝试执行 git push --set-upstream origin feature/US12376 命令,但遇到错误:

error: update_ref failed for ref 'refs/remotes/origin/feature/US12376': cannot lock ref 'refs/remotes/origin/feature/US12376': 'refs/remotes/origin/feature/US12376/patchFix' exists; cannot create 'refs/remotes/origin/feature/US12376'

远程分支refs/remotes/origin/feature/US12376/patchFix已被删除。


1
你是否仍然在本地引用它?尝试使用 git remote prune origin - crea1
@crea1 是的,它确实很有帮助,谢谢。请添加答案 :) - Sergii
好的,我会将其添加为答案 :) - crea1
1个回答

5
本地 git 仓库仍然引用了 refs/remotes/origin/feature/US12376/patchFix,即使它已经在远程被删除。
你可以运行以下命令来移除这些引用:
git remote prune origin 

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接