GitHub: Clone succeeded, but checkout failed

匿名 (未验证) 提交于 2019-12-03 02:48:02

问题:

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' 

回答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.



回答2:

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.



回答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.



回答4:

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.



回答5:

In my case, which is cloning large file on mac OS, the solution was installing:

Git-lfs " Git extension for versioning large files"

https://github.com/git-lfs/git-lfs/wiki/Installation

(on Mac):

brew update brew install git-lfs git lfs install git checkout -f HEAD 

(on Windows):

  1. Download the windows installer from here
  2. Run the windows installer
  3. Start a command prompt/or git for windows prompt and run git lfs install

(on Linux):

sudo apt-get install git-lfs git lfs install 

To learn more about Git LFS

https://www.atlassian.com/git/tutorials/git-lfs



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!