Alexander McFarlane
Alexander McFarlane

Reputation: 11293

GIT "refs/heads/gh-pages does not point to a valid object!"

Q: How can I resolve the following errors?

    error: refs/heads/gh-pages does not point to a valid object!
    error: refs/remotes/origin/gh-pages does not point to a valid object!
    error: refs/stash does not point to a valid object!

git status and git log both work fine

Origin

I deleted the following file to free up some space as it was a colossal 2GB as I assumed it was part of a huge 2GB file I had committed and had attempted to remove with bfg. I assumed this was the last trace of it.

rm ./.git/objects/pack/pack-bec4156621c0ce105abeedad0878eedf59f10a31.pack

Debugging

Using $GIT_TRACE=1 git pull I get the output below but I am wary of doing a change that might impact on my actual repository contents.

15:09:45.684046 git.c:344               trace: built-in: git 'pull'
15:09:45.684942 run-command.c:334       trace: run_command: 'fetch' '--update-head-ok'
15:09:45.685426 exec_cmd.c:189          trace: exec: 'git' 'fetch' '--update-head-ok'
15:09:45.687727 git.c:344               trace: built-in: git 'fetch' '--update-head-ok'
error: refs/heads/gh-pages does not point to a valid object!
error: refs/remotes/origin/gh-pages does not point to a valid object!
error: refs/stash does not point to a valid object!
15:09:45.692615 run-command.c:334       trace: run_command: 'git-remote-https' 'origin' 'https://github.com/flipdazed/Hybrid-Monte-Carlo.git'
error: refs/heads/gh-pages does not point to a valid object!
error: refs/remotes/origin/gh-pages does not point to a valid object!
error: refs/stash does not point to a valid object!
15:09:46.658813 run-command.c:334       trace: run_command: 'rev-list' '--objects' '--stdin' '--not' '--all' '--quiet'
15:09:46.667707 run-command.c:334       trace: run_command: 'rev-list' '--objects' '--stdin' '--not' '--all'
15:09:46.668230 exec_cmd.c:189          trace: exec: 'git' 'rev-list' '--objects' '--stdin' '--not' '--all'
15:09:46.670683 git.c:344               trace: built-in: git 'rev-list' '--objects' '--stdin' '--not' '--all'
error: refs/heads/gh-pages does not point to a valid object!
error: refs/remotes/origin/gh-pages does not point to a valid object!
error: refs/stash does not point to a valid object!
error: refs/heads/gh-pages does not point to a valid object!
error: refs/remotes/origin/gh-pages does not point to a valid object!
error: refs/stash does not point to a valid object!
15:09:46.674636 run-command.c:334       trace: run_command: 'gc' '--auto'
15:09:46.675101 exec_cmd.c:189          trace: exec: 'git' 'gc' '--auto'
15:09:46.677382 git.c:344               trace: built-in: git 'gc' '--auto'
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

Upvotes: 1

Views: 5169

Answers (1)

ElpieKay
ElpieKay

Reputation: 30888

You should not delete any of the .pack files, which pack up a lot of your commits. Since it was deleted, you have lost many of your commits, including the one which refs/heads/gh-pages points to. If you have pushed all of your local refs to another repo, you could fetch them back or make another clone. But if you haven't, maybe you need some tool to restore the deleted data from your hard disk.

Usually Git stores loose objects(including commit, tree, blob and annotated tag) in .git/objects/. For example, if there is a commit whose sha1 is 1daa24d58e28ee48365d594e90ebb215ddd47809, you could find it as .git/objects/1d/aa24d58e28ee48365d594e90ebb215ddd47809. In order to save space further, Git packs them up into .pack and .idx and stores them in .git/objects/pack via git gc which is run by hand or automatically.

Reference:Git Internals

Upvotes: 1

Related Questions