簡體   English   中英

git pull 因錯誤文件名太長而中止

[英]git pull aborted with error filename too long

我使用 Windows 作為我的操作系統,並與一位使用 Mac 的朋友一起從事一個項目。 他將代碼簽入了我們的 Github。

我試圖 git pull 他所做的一切,但它因 3rd 方代碼的“文件名太長”錯誤而中止。

我能做什么?

Git上的 msysgit FAQ cannot create a filedirectory with a long path似乎不是最新的,因為它仍然鏈接到舊的 msysgit ticket #110 但是,根據后來的票 #122,該問題已在 msysgit 1.9 中得到解決,因此:

  1. 更新到 msysgit 1.9(或更高版本)
  2. 啟動 Git Bash
  3. 轉到“遭受”長路徑問題的 Git 存儲庫
  4. 使用git config core.longpaths true啟用長路徑支持

到目前為止,它對我來說效果很好。

請注意 票據#122評論中的重要通知

不要回到這里抱怨它破壞了 Windows 資源管理器、cmd.exe、bash 或您正在使用的任何工具。

解決方案 1 - 通過運行以下命令設置全局配置:

git config --system core.longpaths true

解決方案 2 - 或者您可以直接編輯您的特定 git 配置文件,如下所示:

YourRepoFolder -> .git -> 配置:

[core]
    repositoryformatversion = 0
    filemode = false
    ...
    longpaths = true        <-- (add this line under core section)

解決方案 3 - 克隆新存儲庫時:此處

晚了幾年,但我想補充一點,如果您需要一舉完成(就像我一樣),您可以在克隆命令期間設置配置設置。 嘗試這個:

git clone -c core.longpaths=true <your.url.here>

打開您的 .gitconfig 文件以添加 longpaths 屬性。 所以它看起來像下面這樣:

[core]
symlinks = false
autocrlf = true
longpaths = true

作為在 Windows 上使用 java 存儲庫不斷遇到此問題的人,最好的解決方案是安裝 Cygwin ( https://www.cygwin.com/ ) 並在 all > devel > git 下使用其 git 安裝。

這是我遇到的最佳解決方案的原因是因為 Cygwin 管理長路徑名稱,因此其他提供的命令受益。 例如:查找、cp 和 rm。 相信我,當您必須刪除 Windows 中太長的路徑名時,真正的問題就開始了。

盡量讓您的文件靠近文件系統根目錄。 更多細節:由於技術原因, 當絕對路徑超過 260 個字符時Git for Windows 無法創建文件或目錄

在 Windows 上以管理員身份運行“cmd”並執行命令。

"C:\Program Files\Git\mingw64\etc>"
"git config --system core.longpaths true"

或者你必須為安裝了 git 的文件夾 chmod 。

或 manullay 通過轉到路徑“Git\\mingw64\\etc”手動更新您的文件

[http]
    sslBackend = schannel
[diff "astextplain"]
    textconv = astextplain
[filter "lfs"]
    clean = git-lfs clean -- %f
    smudge = git-lfs smudge -- %f
    process = git-lfs filter-process
    required = true
[credential]
    helper = manager
**[core]
    longpaths = true**

暫無
暫無

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

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