jamie_y
jamie_y

Reputation: 1929

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'

Upvotes: 108

Views: 286110

Answers (22)

Mykola Khyliuk
Mykola Khyliuk

Reputation: 1423

In my case it was a trailing space in the file name, so git clone failed on Windows. After space removing and pushing the changes from Linux, it started working on Windows too.

Upvotes: 0

ali
ali

Reputation: 1

you can configure Git to ignore the NTFS naming may fix the issue.

git config --global core.protectNTFS false

Upvotes: -2

Ibo
Ibo

Reputation: 109

Previous answers are correct. But if you have "permission denied" issues, they will not work, so you need the following:

git clone --config core.longpaths=true repository_url

So, you say that you do not set it globally, instead you set it just for this call. And the message will disappear also with permission denied.

Upvotes: 1

Ammar Mujeeb
Ammar Mujeeb

Reputation: 1321

Installing GIT LFS from its website works well for me. Steps are follows:

  1. Download relevant binary from the web
  2. From terminal navigate to the downloaded folder by cd (path can be populated by dragging this folder to terminal)
  3. Run sudo ./install.sh

Upvotes: 0

Ihor Volkov
Ihor Volkov

Reputation: 43

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.

Upvotes: 1

leila-m
leila-m

Reputation: 125

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.

Upvotes: 0

KaranKulshrestha
KaranKulshrestha

Reputation: 318

Go to the git clone folder and run this command

git restore --source=HEAD :/

Upvotes: 3

coder618
coder618

Reputation: 1014

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

Upvotes: 16

Franck Theeten
Franck Theeten

Reputation: 140

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

Upvotes: 0

Shweta
Shweta

Reputation: 799

In my case only one command fixed the issue.

git reset

enter image description here

Upvotes: 1

Arun Prasad E S
Arun Prasad E S

Reputation: 10145

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

Then cloned again, it worked.

Upvotes: 0

surajmall
surajmall

Reputation: 196

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.

Upvotes: 0

alamin39
alamin39

Reputation: 211

This worked for me

git config --global core.longpaths true

Upvotes: 11

Vedad Herceglija
Vedad Herceglija

Reputation: 63

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 *

Upvotes: 4

Jai Prakash
Jai Prakash

Reputation: 2799

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


git config --system core.longpaths true

Upvotes: 91

Paschal Amah
Paschal Amah

Reputation: 101

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

Upvotes: 9

Gustavo Braga
Gustavo Braga

Reputation: 91

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

Upvotes: 9

Gaurav Khare
Gaurav Khare

Reputation: 2327

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

Upvotes: 6

salle55
salle55

Reputation: 2181

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.

Upvotes: 25

user3579815
user3579815

Reputation: 572

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.

Upvotes: 25

jamie_y
jamie_y

Reputation: 1929

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.

Upvotes: 3

vonbrand
vonbrand

Reputation: 11831

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.

Upvotes: 33

Related Questions