摆脱旧 git 分支的“...不指向有效对象" [英] Getting rid of '... does not point to a valid object' for an old git branch

查看:35
本文介绍了摆脱旧 git 分支的“...不指向有效对象"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Git 存储库的分支,而我的克隆似乎有一个旧的、不再存在的分支的问题.我一直看到这条消息:

I have a fork of a Git repo and my clone appears to have an issue with an old, no longer existant, branch. I keep seeing this message:

错误:refs/heads/t_1140 未指向有效对象!

我没有任何其他消息,而且 repo 工作正常.没有任何操作可以阻止我在其他分支上工作,推送更改,拉取...等.

I don't have any other messages and the repo works fine. There's no operation that stops me from working on other branches, pushing changes, pulling...etc.

我环顾四周,但关于如何解决此问题的说明并不明确.我尝试执行 git fsck --full 但我没有看到任何错误.只是悬空...... 消息的负载.

I've looked around and there's less than clear instructions on how to get around this issue. I've tried to execute git fsck --full but I see no errors. Just a load on dangling ... messages.

我还检查了我的 .git/config 并且没有对该分支的引用,并且还检查了 .git/refs/heads 并且没有引用 <代码>t_1140

I've also checked my .git/config and there's no references to this branch and have also checked .git/refs/heads and there's no reference to t_1140

知道如何摆脱这个错误吗?

Any idea how to get rid of this error?

p.s 我再次尝试克隆我的 repo,似乎错误也是我的 Github repo.所以,我现在唯一能想到的就是放弃我的 repo 并再次分叉.

p.s I've tried to clone my repo again and it seems like the error is my Github repo too. So, the only thing I can think of right now is to ditch my repo and fork again.

推荐答案

这将清除任何丢失的参考:

This will clean out any missing refs:

git for-each-ref --format="%(refname)" | while read ref; do
    git show-ref --quiet --verify $ref 2>/dev/null || git update-ref -d $ref
done

这篇关于摆脱旧 git 分支的“...不指向有效对象"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆