簡體   English   中英

GitHub:克隆成功,但檢出失敗

[英]GitHub: Clone succeeded, but checkout failed

我在使用git clone時遇到了一些問題。文件下載到我的本地 git 文件夾中。 運行命令

git checkout -f HEAD給我-

錯誤:

'磁盤空間不足導致的無法寫入新索引文件錯誤'。

我已手動從計算機中刪除了大文件,但仍然出現相同的錯誤。

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'

克隆時,git 會從遠程端獲取所有對象(壓縮並保存到.git目錄中)。 一旦它擁有所有部分,它就會繼續解壓縮(重新)創建工作目錄所需的所有文件。 由於沒有足夠的空間,這一步失敗了。 這可能是由於磁盤已滿或超出磁盤配額(在共享計算機上,通常強制執行配額以避免用戶占用的空間超過其公平份額)。

刪除你的 cruft。 確保您沒有試圖將 Linux 內核或某些此類龐大的存儲庫壓縮到您的幾兆帳戶空間中。

對我來說,這是由於長文件名和做一個簡單的配置如下解決它


git config --system core.longpaths true

就我而言,我的磁盤未滿,這是我解決的方法:

  1. cd 進入項目目錄並通過運行git reset取消暫存所有暫存文件(如果有)
  2. 通過運行git checkout *撤消工作目錄中的所有更改git checkout *

完成這兩個步驟后,您應該能夠看到項目文件。

我最近遇到了這個問題,錯誤是我克隆存儲庫的文件路徑太大,您可以通過將存儲庫克隆到 C:\\ 中的某個文件夾來進行測試

嘗試從 Visual Studio 2017 (v15.6.0) 克隆存儲庫時遇到相同的錯誤。

在我的情況下,在本地安裝GIT-LFS解決了這個問題。

除了其他可能性之外,主要的可能是 Windows 對命名文件施加的規則。 git clone 和 checkout 在 linux 上應該可以正常工作。

有關更多信息,請觀看此 - https://github.com/msysgit/msysgit/issues/208

在我的情況下,這是由於文件名中的冒號 一旦我改變了它們,一切都很好。

我解決了這個問題。 原來我的磁盤已滿。 你可以通過運行找到

quota

我的結果說

$ quota

Home Area quota for: jamie_y

Current Usage: 8 GB
Current Limit: 8 GB

運行 du 命令以查找您的磁盤使用情況。

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)

運行 rm -rf folderName 刪除文件夾/文件。

這對我有用

git 配置 --global core.longpaths true

如果你在 Windows 上,你應該這樣做:

  1. 轉到gpedit.msc計算機配置 → 管理模板 → 系統 → 文件系統,打開Enable Win32 long paths並將其設置為Enabled

  2. 之后git config --system core.longpaths true或編輯gitconfig (您必須以管理員身份運行)。

  3. git bash打開項目目錄,然后運行git reset運行git checkout *

發生這種情況是因為您的文件可能太大。 我嘗試通過 GitHub 桌面應用程序克隆存儲庫,它解決了我的問題。

就我而言 - 一個文件名太長,我使用 GitLab 網站刪除了該特定文件。

然后再次克隆,它工作。

在我的情況下,只有一個命令解決了這個問題。

git 復位

在此處輸入圖像描述

我遇到了同樣的錯誤,因為我的計算機的防病毒軟件在下載和結帳之間刪除了文件(在我的例子中是帶有 VBA 宏的 Excel)。 從遠程分支中刪除有問題的文件解決了這個問題(或者如果可以的話,禁用防病毒軟件)。

就我而言,我通過以下方式解決了這個問題:

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

資源清單:

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

我的驅動器未滿

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM