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

匿名 (未验证) 提交于 2019-12-03 02:45:02

问题:

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

 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:

 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:

 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:

回答1:

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!



回答2:

Typically you can do:

git reflog master 

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

Once you know this you can create a temporary branch to an older version of 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.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!