Fix for the fatal error ‘early EOF’ on git clone

Recently I cloned a large remote git repository into my localhost, but failed and I got the error:

Cloning into 'D:\xampp\path\to\my\folder'...
POST git-upload-pack (350 bytes)
remote: Counting objects: 7544, done.
remote: Compressing objects: 100% (3985/3985), done.
fatal: early EOF
fatal: The remote end hung up unexpectedly
fatal: index-pack failed

I tried again and again because I thought that it would be a problem of slow internet connection (internet speed is slow in our country; working on high speed internet is my dream 😉 ). Same error occurred. Then, I googled and found a solution.

1. turn off compression:
git config --global core.compression 0

2. do a partial clone to truncate the amount of info coming down:
git clone --depth 1 <my_repo_URI>

3. retrieve the rest of the clone:
git fetch --unshallow

4. do a regular pull:
git pull --all

Some say that there may be a glitch with msysgit in the 1.8.x versions and to try an earlier version of git (<= 1.8.3) as another option. At this time of writing, the latest version is 1.9.4.

Unfortunately, after I have done above, I did not see all of the remote branches except the master branch in my local clone. However I found myself a fix. I tweaked the git config file to change

fetch = +refs/heads/master:refs/remotes/origin/master
to
fetch = +refs/heads/*:refs/remotes/origin/*

Then, $ git fetch --all worked for the changes.

Fetching origin
Password for 'https://myusername@bitbucket.org':
remote: Counting objects: 993, done.
remote: Compressing objects: 100% (581/581), done.
Receiving objects: 100% (966/966), 723.76 KiB | 8.00 KiB/s, done.
remote: Total 966 (delta 324), reused 964 (delta 322)Resolving deltas: 0%

Resolving deltas: 100% (324/324), completed with 21 local objects.
From https://bitbucket.org/myusername/myproj
* [new branch] etc/schema_note -> origin/etc/schema_note
* [new branch] feature/sampledata -> origin/feature/sampledata
* [new branch] fix/cleanup -> origin/fix/cleanup

Now, $ git branch -a started to list all remote branches;

* master
remotes/origin/HEAD -> origin/master
remotes/origin/etc/schema_note
remotes/origin/feature/sampledata
remotes/origin/fix/cleanup
remotes/origin/master

Finally, I checkout for every branch.

$ git checkout etc/schema_note
Branch etc/schema_note set up to track remote branch etc/schema_note from origin.
Switched to a new branch 'etc/schema_note'

$ git checkout feature/sampledata
Branch feature/sampledata set up to track remote branch feature/sampledata from
origin.
Switched to a new branch 'feature/sampledata'

$ git checkout fix/cleanup
Branch fix/cleanup set up to track remote branch fix/cleanup from origin.
Switched to a new branch 'fix/cleanup'

If you don’t want to checkout each branch, you could alternatively try git branch –track:

$ git branch --track etc/schema_note origin/etc/schema_note
$ git branch --track feature/sampledata origin/feature/sampledata
$ git branch --track fix/cleanup origin/fix/cleanup

Here is my final repo branch list:

$ git branch -a
etc/schema_note
feature/sampledata
* fix/cleanup
master
remotes/origin/HEAD -> origin/master
remotes/origin/etc/schema_note
remotes/origin/feature/sampledata
remotes/origin/fix/cleanup
remotes/origin/master

Advertisements

One thought on “Fix for the fatal error ‘early EOF’ on git clone

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s