Git refs/remotes/origin/master 未指向有效对象

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13881609/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 15:05:52  来源:igfitidea点击:

Git refs/remotes/origin/master does not point to a valid object

git

提问by Matt Harasymczuk

After the last merge to the master branch of my Git repository I have lost the ability to clone repository.

在最后一次合并到我的 Git 存储库的主分支后,我失去了克隆存储库的能力。

Cloning into test-repository...
remote: Counting objects: 126084, done.
remote: Compressing objects: 100% (28327/28327), done.
Receiving objects: 100% (126084/126084), 132.63 MiB | 29.30 MiB/s, done.
remote: Total 126084 (delta 96101), reused 126078 (delta 96095)
Resolving deltas: 100% (96101/96101), done.
error: refs/remotes/origin/master does not point to a valid object!
error: Trying to write ref refs/heads/master with 
       nonexistant object 951aca8051823b2f202d30c9cb05401ef17618c6

Fisheye, a repository hosting tool, is reporting:

存储库托管工具 Fisheye 报告:

Unable to fetch from remote repository:
/var/atlassian/application-data/fisheye/managed-repos/MYREPONAME.git
error: unable to find 0d998c99b6d01e8aabca72b1934802acf90b8fc9,
fatal: object 0d998c99b6d01e8aabca72b1934802acf90b8fc9 not found

The last commit in the repository on master branch is:

master 分支上存储库中的最后一次提交是:

commit 0d998c99b6d01e8aabca72b1934802acf90b8fc9
Merge: a6ea4b3 1f373a9
Date:   Fri Dec 14 13:57:24 2012 +0200

Merge branch 'new_error_code'

I have tried:

我试过了:

cd /var/atlassian/application-data/fisheye/managed-repos/MYREPONAME.git
git gc
git fsck --full
git reflog expire --expire=0 --all
git update-ref
git gc --aggressive

The following questions did not help my case:

以下问题对我的案子没有帮助:

回答by Matt Harasymczuk

git gc
git fsck --full
git reflog expire --expire=0 --all
git update-ref -d 0d998c99b6d01e8aabca72b1934802acf90b8fc9
git gc --aggressive
git remote update --prune

and it worked!

它奏效了!

回答by MrUnleaded

Typically you can do:

通常你可以这样做:

git reflog master

This will give you a list of the last know positions that master has pointed to.

这将为您提供 master 指向的最后一个已知位置的列表。

Once you know this you can create a temporary branch to an older version of master ie

一旦你知道这一点,你就可以创建一个临时分支到旧版本的 master ie

git branch temp master@{1}

Then checkout temp and see if it is in proper order. If you don't see anything there then the commands that you did previously (delete the reflog, delete dangling commits, etc) have probably wiped out all ways to recovery.

然后结帐温度,看看它是否在正确的顺序。如果您在那里没有看到任何内容,那么您之前执行的命令(删除引用日志、删除悬空提交等)可能已经消除了所有恢复方法。