GitHub: Clone succeeded, but checkout failed

I am having some problems working with git clone.The files are downloaded in my local git folder. Running the command

git checkout -f HEAD gives me-

Error:

'The unable to write new index file error caused by the lack of disk space'.

I've manually removed big files from my computer, but still getting the same error.

Cloning into 'ffmpeg'...
remote: Counting objects: 7890, done.
remote: Compressing objects: 100% (4412/4412), done.
Receiving objects: 100% (7890/7890), 299.75 MiB | 24.19 MiB/s, done.
remote: Total 7890 (delta 3346), reused 7846 (delta 3317)
Resolving deltas: 100% (3346/3346), done.
Checking out files: 100% (7019/7019), done.
fatal: unable to write new index file
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'
8

14 Answers

For me this was due to long file names and doing a simple config as below resolved it

git config --system core.longpaths true
1

When you clone, git gets all the objects from the remote end (compressed and stashed into the .git directory). Once it has all the pieces, it proceeds to unpack all files needed to (re)create the working directory. It is this step that fails, due to not having enough space. This might be due to a disk that is full, or a disk quota exceeded (on shared machines, quotas are often enforced to avoid having users grab more than their fair share of space).

Delete your cruft. Make sure you aren't trying to squeeze the Linux kernel or some such monster repository into your few megabytes of account space.

3

In my case my disk was not full and this is how I solved it:

  1. cd into the project directory and un-stage all staged files if any by running git reset
  2. undo all changes in the working directory by running git checkout *

After doing the two steps you should be able to see the project files.

1

Got the same error when trying to clone a repo from Visual Studio 2017 (v15.6.0).

In my case installing GIT-LFS locally solved the issue.

1

I recently had this problem and the error was that the path of the file where I was cloning the repository was too large, you can do a test by cloning the repository into some folder in C:\

3

Apart from other possibilities, the major one could be rules imposed by windows on naming files. The git clone and checkout should work fine on linux.

For more info watch this -

2

In my case it was due to colons in filenames. Once I changed them, everything worked fine.

2

I solved the problem. It turns out that my disk was full. You can find out by running

quota

My result said

$ quota
Home Area quota for: jamie_y
Current Usage: 8 GB
Current Limit: 8 GB

Run du command to find your disk usage.

The du command shows the disk space used by the files and directories in a directory. The -h option makes the output easier to read, and the -s option summarizes the result. For example, du -h -s (quoted from )

Run rm -rf folderName to remove the folder/file.

If you are on windows, you should do:

  1. Go to Computer Configuration → Administrative Templates → System → Filesystem in gpedit.msc , open Enable Win32 long paths and set it to Enabled.

  2. After that git config --system core.longpaths true or edit gitconfig (you must run as administrator).

  3. Open project directory with git bash and run git reset after that run git checkout *

1

This worked for me

git config --global core.longpaths true

It's happening because may be your files are too large. I tried to clone the repository through GitHub Desktop application and it solved my issue.

In my case - one file name was too long, I used the GitLab website to delete that particular file.

Then cloned again, it worked.

In my case only one command fixed the issue.

git reset

enter image description here

I had the same error, due to the fact that the antivirus of my computer was removing files between download and checkout (Excel with VBA macros in my case). Removing the problematic files from the remote branch solved the issue (or disable the antivirus if you can).

You Might Also Like