我如何 git 以最佳方式拉取服务器?

How can I git pull on the server optimally?

这两天我试图将我的项目(在 git 上)拉到我的服务器上。我的服务器有 1GB 内存并使用 Ubuntu OS。 (其他进程通常使用 200mb 的 RAM)

当我在服务器上 运行 git pull origin master 时,它会抛出这个:

fatal: Out of memory, malloc failed (tried to allocate 533517295 bytes)

fatal: index-pack failed

这也是nano .git/config的结果:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    packedGitLimit = 512m
    packedGitWindowSize = 512m

[remote "origin"]
    url = https://***@bitbucket.org/***/***.g$
    fetch = +refs/heads/*:refs/remotes/origin/*

[pack]
  threads = 1
  deltaCacheSize = 512m
  packSizeLimit = 512m
  windowMemory = 512m

老实说,我无法为我的服务器获得更多 RAM。知道如何将我的项目拉到服务器上吗?

注意到现实中有真实姓名而不是***

要限制提取操作期间使用的内存量(git pull 使用 git fetch),您可以使用 --depth 标志。

只是 运行 git pull --depth=10 并增加数字以获取越来越多的历史记录(或者如果您也 运行 内存不足则减少它)。一旦历史中加载了足够的对象,就可以使用 git fetch --unshallow

请求剩余对象

深度拉取的缺点是您的存储库将在磁盘上占用更多 space,因为它还必须考虑存储库的多种状态