bash 警告:忽略损坏的 refs/remotes/origin/HEAD
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45811971/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
warning: ignoring broken ref refs/remotes/origin/HEAD
提问by sensorario
Since a few days ago, every time I press tabkey to complete branch names in bash I see the message:
从几天前开始,每次我tab在 bash 中按键完成分支名称时,我都会看到以下消息:
warning: ignoring broken ref refs/remotes/origin/HEAD warning: ignoring broken ref refs/remotes/origin/HEAD
警告:忽略损坏的 ref refs/remotes/origin/HEAD 警告:忽略损坏的 ref refs/remotes/origin/HEAD
For example, this is what I see when I have a branch called feature/foo and I press tab:
例如,当我有一个名为 feature/foo 的分支并按下 时,我看到的是tab:
git checkout f
$ git checkout fwarning: ignoring broken ref refs/remotes/origin/HEAD
warning: ignoring broken ref refs/remotes/origin/HEAD
eature/
回答by kdechant
I encountered this recently when someone on my team deleted our old development branch from the remote. I ran this command to check the status of HEAD:
最近当我团队中的某个人从远程删除了我们的旧开发分支时,我遇到了这个问题。我运行这个命令来检查 HEAD 的状态:
$ git symbolic-ref refs/remotes/origin/HEAD
refs/remotes/origin/old_dev
This command output the name of the old development branch, which no longer exists.
此命令输出不再存在的旧开发分支的名称。
I fixed the warnings using this:
我用这个修复了警告:
$ git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/new_dev
(Where "new_dev" is a branch name. Replace it with the name of the branch you want HEAD to point to.)
(其中“new_dev”是分支名称。将其替换为您希望 HEAD 指向的分支的名称。)
回答by Paulo Coghi - Reinstate Monica
This is a simpler solution than symbolic-ref.
这是比符号引用更简单的解决方案。
Since you may have excludedthe branch that origin/HEADwas initially pointed to.
因为您可能已经排除了origin/HEAD最初指向的分支。
1. List your remote branches with:
1. 列出你的远程分支:
git branch -r
2. If it doesn't show in the results:
2. 如果没有显示在结果中:
origin/HEAD -> origin/(something)
3. Just point it again with:
3. 再次指出它:
git remote set-head origin master
where "master" is the name of your primary (head) branch.
其中“master”是您的主要(头)分支的名称。
Running git branch -r
again now shows origin/HEAD -> origin/(something)
and the warning goes away.
git branch -r
现在再次运行显示origin/HEAD -> origin/(something)
,警告消失。
回答by simonbor
Just run the command -
只需运行命令 -
git remote set-head origin master
Enjoy!
享受!
回答by zigarn
Looks like the default branch of your remote origin
doesn't exists anymore.
Fix the default branch of the remote:
看起来您的遥控器的默认分支origin
不再存在。
修复遥控器的默认分支:
- GitHub: https://github.com/USER_OR_ORG/REPOSITORY/settings/branches-> "Default branch"
- Bitbucket Cloud: https://bitbucket.org/USER_OR_ORG/REPOSITORY/admin-> " Main branch"
- Bitbucket Server: http://git.sid.distribution.edf.fr/projects/PROJECT/repos/REPOSITORY/settings-> "Default branch"
- GitHub:https: //github.com/USER_OR_ORG/REPOSITORY/settings/branches->“默认分支”
- Bitbucket 云:https: //bitbucket.org/USER_OR_ORG/REPOSITORY/admin-> “主分支”
- Bitbucket 服务器:http: //git.sid.distribution.edf.fr/projects/PROJECT/repos/REPOSITORY/settings->“默认分支”