git - 防止下载整个 git 存储库

标签 git github

我有一个我正在开发的业余游戏的 git 存储库,我将其推送到 github 上的私有(private)存储库作为代码的备份和中央位置。

在旧版本中,我有 100MB 左右的 .TGA 文件作为纹理,但我在新版本中将它们更改为更小的 .DDS 文件。

但据我所知,当您从 github 克隆存储库时,它仍然会下载所有未使用的旧文件,而不仅仅是最新提交中的文件。这是有意义的,因为您正在克隆存储库,而不仅仅是检查当前版本。但大多数时候它们是无用的大下载量。

但是有什么方法可以阻止它从最旧的版本下载文件,而不妨碍我在需要时获取它们?

如果做不到这一点,我该如何从我的远程存储库中删除那些旧的修订版和不再使用的文件?

最佳答案

从 GitHub 克隆它时使用 --depth 选项,以仅获取最新修订版。

git clone --depth=1 https://github.com/user/repo

来自手册...

Create a shallow clone with a history truncated to the specified number of revisions. A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches.

如果您想知道 Git 命令有哪些选项,可以使用 git help commandman git-command

关于git - 防止下载整个 git 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13438960/

相关文章:

github - 如何在 Github 上请求 OAuth 应用程序的重新授权?

git - 如何在 git 中添加另一个存储库?

github - 发布Monthrepo的Github软件包作为组织的一部分

windows - 推送到 Azure DevOps git 存储库 : GCM: NullReferenceException

css - 来自 github 版本的外部样式表不加载

linux - 尝试 Git 克隆时权限被拒绝(公钥)

git - grep 用于多个 git 存储库中的内容

windows - Git - 切换分支(窗口)和未提交的更改

windows - 错误的解释器 : Permission denied error when running Ruby from Git Bash

git - 如何使用 Visual Studio Tools for Git v0.8.5.1 git stash