cloning error when checking out private github rep

2019-01-29 11:27发布

问题:

I get the following error while cloning a private repo on my colleagues computer:

Cloning into xxx...
remote: Counting objects: 7112, done.
remote: Compressing objects: 100% (4870/4870), done.
remote: Total 7112 (delta 2281), reused 6503 (delta 1672)
Receiving objects: 100% (7112/7112), 10.88 MiB | 975 KiB/s, done.
Resolving deltas: 100% (2281/2281), done.
error: refs/remotes/origin/master does not point to a valid object!
error: Trying to write ref refs/heads/master with nonexistant object 5f1f9967f0d76f1f5af4ebc1d1b0dd5dcbf593c5
fatal: Cannot update the ref 'HEAD'.

It works fine on my own computer, and i can't figure out what the problem is, it does not seem to be connected to the repo itself. As it clones fine on other computers.

Changing the directory where i check out in doesn't seem to work fighter.

  • O/S: Mac OSX Lion
  • System: Macbook Pro (Jul 2011) 8GB Ram

$ git version git version 1.7.5.4

回答1:

The answer:

I created a branch, (git checkout -b master2) then pushed the branch. Then i deleted master and renamed master2 to master.

Finally worked.



回答2:

In case anyone else ends up here with this problem, I discovered that the version of git that comes with Ubuntu 11.10 (version 1.7.5.4) seems to have problems cloning and pulling from repos created by later versions (my local machine was running git 1.7.9.5).

Since sudo apt-get update will only pull down an old version of git, I had no choice but to build it manually. Fortunately, these instructions were great, and in no time I had git 1.8.0.2 running on the server, which pulled down the repo with no problems at all.

I'm sure there are lots of other reasons why you might see this message, but upgrading git could be a painless first attempt before you start cloning, forking and deleting...