87

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'
Sandeep Chatterjee
  • 3,220
  • 9
  • 31
  • 47
jamie_y
  • 1,719
  • 2
  • 13
  • 20
  • by default its master I suppose and git checkout -f HEAD do u have a branch called HEAD ? – Abhik Chakraborty Feb 26 '14 at 12:49
  • Yes. I have a folder called HEAD inside of .git folder. Should I remove that folder? – jamie_y Feb 26 '14 at 12:57
  • no dont delete anything inside .git folder – Abhik Chakraborty Feb 26 '14 at 13:03
  • once you do a git clone it will create a folder and that folder is your app directory and inside that folder you will have the .git folder. Your app/code folder is not linked to git and using git checkout {branchname} you can checkout to different branches – Abhik Chakraborty Feb 26 '14 at 13:05
  • Thanks! I put the source code under .git/branches. Is that okay? And do you know how to solve that lack of disk space error? – jamie_y Feb 26 '14 at 13:18
  • What OS you are using ? You can delete some un-necessary files if its in local. If its in server I would suggest to ask someone (server admin to clean up some space) – Abhik Chakraborty Feb 26 '14 at 13:22
  • Okay. I will ask my server admin to clear up some space! – jamie_y Feb 26 '14 at 13:46
  • @jamie_y, what is under `.git` is *strictly* git's bussiness. You can go sightseeing in there, but only with hands firmly seated in the pockets. – vonbrand Feb 26 '14 at 14:46

18 Answers18

67

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


git config --system core.longpaths true
Jai Prakash
  • 2,461
  • 1
  • 26
  • 27
  • 6
    nice.. i've been edited C:\Program Files\Git\etc\gitconfig and inserted longpaths = true in [core] tag. or.. git config --global core.longpaths true it's worked to me. tks – Elson Costa Oct 28 '21 at 19:49
33

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.

vonbrand
  • 11,412
  • 8
  • 32
  • 52
22

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.

user3579815
  • 522
  • 3
  • 12
  • Right, forgot about that. If the final checkout would overwrite local files, it fails. You can `git stage` them out of the way (for now). – vonbrand Jun 18 '19 at 17:07
20

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.

salle55
  • 2,101
  • 2
  • 25
  • 27
  • 3
    It was the case here as well ... the error message was ... ```git-lfs filter-process: git-lfs: command not found fatal: the remote end hung up unexpectedly warning: Clone succeeded, but checkout failed. You can inspect what was checked out with 'git status' and retry with 'git restore --source=HEAD :/``` ...Installing git-lfs resolved the issue – predmod Sep 28 '20 at 16:22
9

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:\

Gustavo Braga
  • 91
  • 1
  • 2
9

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

Paschal Amah
  • 101
  • 1
  • 1
  • same for me , removed colons and no more issue. – Ray Jun 27 '21 at 05:32
  • 4
    I think mine is caused by a space on the end of the file -- but how do you correct that when you're not the owner of the repo? error: invalid path 'hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_6_0/2837-search-with-not-modifier-on-multiple-codes.yaml ' – Uncle Iroh Sep 13 '21 at 23:31
6

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 - https://github.com/msysgit/msysgit/issues/208

Gaurav Khare
  • 2,203
  • 4
  • 25
  • 23
  • 1
    This was our issue. Filename beginning with a quote. Deleted it on a Linux machine and it was solved. – Pickled Oct 31 '18 at 16:13
  • I was also facing the same problem, in my case directory name was ending with '.'(dot) which was working fine on Ubuntu/Mac but not on windows... – Wasit Shafi Mar 14 '21 at 04:49
5

This worked for me

git config --global core.longpaths true

alamin39
  • 151
  • 1
  • 8
5

In my case I solved this problem by :

  1. install git LFS
  2. git config --system core.longpaths true
  3. git config --global core.protectNTFS false

resource list:

  1. https://git-lfs.github.com/
  2. https://confluence.atlassian.com/bitbucketserverkb/error-invalid-path-during-git-clone-to-windows-client-1085186345.html

My drive was not Full

coder618
  • 848
  • 1
  • 9
  • 12
4

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 *

bad_coder
  • 11,289
  • 20
  • 44
  • 72
3

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 http://linux.about.com/od/commands/a/blcmdl1_dux.htm)

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

jamie_y
  • 1,719
  • 2
  • 13
  • 20
1

In my case only one command fixed the issue.

git reset

enter image description here

Shweta
  • 661
  • 6
  • 11
1

Go to the git clone folder and run this command

git restore --source=HEAD :/
0

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.

surajmall
  • 178
  • 1
  • 7
0

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

Then cloned again, it worked.

Arun Prasad E S
  • 9,489
  • 8
  • 74
  • 87
0

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).

0

I was having this problem with git bash. Cloned in Ubuntu terminal instead using HTTP and not SSH and it worked immediately after I authenticated in the terminal.

leila-m
  • 97
  • 1
  • 9
0

If you are using Windows, make sure that the file name is not include in the system reserved name: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file

In my case it was a file named com9 which was causing issues.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 02 '23 at 00:46