[英]Why git sparse checkout result in fatal error?
這是我對git
的命令,我在 Windows 中運行以從 repo 中稀疏結帳文件夾:
git clone --verbose --filter=blob:none --no-checkout --depth 1 --sparse "https://user:password@github.com/organization/repo-name.git"
cd ./repo-name
git config core.sparseCheckout true
git sparse-checkout init
git sparse-checkout add /MainFolder !/MainFolder/Subfolder
git sparse-checkout add /AnotherFolder
...
git checkout --progress --force
...
並且一切都在我的機器(tm)上完美運行,但突然停止在另一台 Windows 機器(在 Powershell 或 CMD 中)上運行,出現錯誤:
fatal: specify directories rather than patterns. If your directory starts with a '!', pass --skip-checks
我想它在某種程度上符合: git sparse-checkout add /MainFolder !/MainFolder/Subfolder
但是什么?
經過大量嘗試/捕獲后,我發現此命令可以正常工作:
git sparse-checkout add MainFolder
但是這個命令(文件夾名稱前有斜杠)
git sparse-checkout add /MainFolder
導致錯誤: fatal: specify directories rather than patterns (no leading slash)
....
我需要在第二台機器上設置/配置什么,以便它繼續在我的機器上工作(包括!/文件夾排除模式)?
PS兩台機器都使用git版本: git version 2.37.1.windows.1
@torek 給出了正確的答案,但我想從自己那里補充:
對使用什么模式的稀疏結帳存在誤解。 上面寫的是一種pattern
樣式 - 所以要讓它工作,我必須禁用這樣的cone
樣式:
git config core.sparseCheckout true
git config --worktree 'core.sparsecheckoutcone' false
接着
git sparse-checkout init
或者只使用 `set' 命令代替所有配置命令,如下所示:
git sparse-checkout set --no-cone
無論如何-我必須禁用cone
模式,所以上面的 git 命令將起作用(包括排除文件夾的特殊符號: !
和其他工作人員)謝謝@torek
您正在使用稀疏結帳的新錐形模式功能。
稀疏結帳現在有兩種模式:模式模式和錐形模式。 模式模式是舊模式,是您使用的模式。 錐形模式是新的默認設置。 它要快得多(或應該快得多),現在不推薦使用模式模式。 但是,錐形模式受到更多限制:有一些稀疏的結帳設置在錐形模式下實際上是不可能的。
如果您不依賴於模式模式,您可以簡單地省略前導斜杠。
有關這方面的更多信息,請參閱git sparse-checkout
文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.