我想克隆一个GitHub仓库,其中包含一个巨大的.exe文件。(为什么呢?!)我对.exe文件完全没有用处,而且它的大小比其他所有文件加在一起还要大得多。有办法在克隆时忽略这个文件吗?我的猜测是我最好向作者请求创建一个不包含exe的分支!希望能有一些好的方法解决这个问题。
2020+:使用更近期的{{link1:git sparse-checkout
命令}}(我在这里介绍):
这将实际上是克隆而不下载任何东西:
git clone --filter=blob:none --no-checkout https://github.com/git/git
cd git
我在这里详细说明排除
# Disablecone mode in .git/config.worktree
git config core.sparseCheckoutCone false
# remove .git\info\sparse-checkout
git sparse-checkout disable
# Add the expected pattern, to include just a subfolder without top files:
git sparse-checkout set !/your.exe
# populate working-tree with only the right files:
git read-tree -mu HEAD
git remote add -f origin <url>
,git config core.sparsecheckout true
,.git/info/sparse-checkout
文件中指定您想要加载的内容。根据您的情况:
/*
!yourExe
git pull origin master
git sparse-checkout
。如果这样做效果更好,请告诉我。 - VonC# Clone without downloading files
git clone --no-checkout --filter=blob:none https://.../<your_git_repo>.git
# Go inside cloned repo
cd <your_git_repo>
# Disable cone mode in .git/config.worktree
git config core.sparseCheckoutCone false
# Remove .git\info\sparse-checkout
git sparse-checkout disable
# Set retrieval to come: all blobs...
git sparse-checkout set '/*'
# ... except this file
git sparse-checkout add '!/<path_to_file_inside_Git_repo>'
# Now download the list of files just set
git read-tree -mu HEAD
git clone
总是会克隆整个仓库,因此我想知道是否有任何方法可以实现我的目标,即不必下载 exe 文件,但又可以使用 git 命令自动化此过程。 - mrKelley