git - 由于引用分支已删除,因此无法获取分支

标签 git git-checkout git-fetch

我试图使用以下命令 pull git 分支 bugfix/validator-integration-bugfix git fetch && git checkout bugfix/validator-integration-bugfix

但我收到以下错误:

akshaykhale$ git fetch && git checkout bugfix/validator-integration-bugfix
error: cannot lock ref 'refs/remotes/origin/bugfix/connection-failure-bugfix': 'refs/remotes/origin/bugfix' exists; cannot create 'refs/remotes/origin/bugfix/connection-failure-bugfix'
From https://github.com/luxio/luxio-framework
 ! [new branch]          bugfix/connection-failure-bugfix -> origin/bugfix/connection-failure-bugfix  (unable to update local ref)
error: cannot lock ref 'refs/remotes/origin/bugfix/migration-datatype-bugfix': 'refs/remotes/origin/bugfix' exists; cannot create 'refs/remotes/origin/bugfix/migration-datatype-bugfix'
 ! [new branch]          bugfix/migration-datatype-bugfix                  -> origin/bugfix/migration-datatype-bugfix  (unable to update local ref)
error: cannot lock ref 'refs/remotes/origin/bugfix/validator-integration-bugfix': 'refs/remotes/origin/bugfix' exists; cannot create 'refs/remotes/origin/bugfix/validator-integration-bugfix'
 ! [new branch]          bugfix/validator-integration-bugfix                           -> origin/bugfix/validator-integration-bugfix  (unable to update local ref)

可能的原因可能是(只是猜测):

我正在获取 bugfix/validator-integration-bugfix 分支,该分支是从其他未在我的开发系统上克隆的分支创建的。

任何解决问题的方法

提前致谢!!!

最佳答案

您团队中的某人创建了一个名为 bugfix 的分支,并将其推送到 origin/bugfix。因此,Git 不允许您创建名称格式为 origin/bugfix/* 的分支。

我猜测该分支被错误地命名为 bugfix,因此解决方案是为该分支指定一个更具描述性的名称。

要在本地重命名 bugfix 分支:

git分支-m bugfix bugfix/sensible-name

然后在 Remote 上重命名它:

git Push origin :bugfix bugfix/sensible-name

然后设置重命名的本地分支来跟踪重命名的远程分支:

git Push origin -u bugfix/sensible-name

关于git - 由于引用分支已删除,因此无法获取分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57724589/

相关文章:

git - 从 git repo 中只提取一个目录

GIT pull error - 远程对象已损坏

git - 我应该使用 `sh -c\"...\"` 还是 `"!f() {... ; }; f"在 git 别名脚本中?

GIT 从裸仓库中 pull

git - git如何跟踪文件的变化

git - 如何在 SourceTree 本地 checkout fork 的 pull 请求?

git - git fetch不起作用-但 checkout 有效

git - 比特桶 :Git on Cygwin - Cannot push to remote repository

git - 我克隆了一个远程分支。如何 checkout 大师?

git - 如何从 git 存储库中只稀疏地 check out 一个文件?