如何配置Git LFS?

发布于:2025-06-07 ⋅ 阅读:(20) ⋅ 点赞:(0)

如何配置Git LFS?

# Ubuntu/Debian 安装git-lfs
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs

# Redhat/CentOS 安装git-lfs
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | sudo bash
sudo yum install git-lfs

# MAC安装git-lfs
brew install git-lfs
git lfs install
git lfs track "*.tar.gz"   # 跟踪tar.gz压缩包
git lfs track "*.zip"      # 跟踪ZIP压缩包
git lfs track "*.dmg"      # 跟踪dmg文件
git lfs track "*.exe"      # 跟踪exe文件

git config --global user.email "test@example.com"
git config --global user.name "test"


git add .gitattributes
git commit -m "Add LFS file tracking"
git push origin

# 增加 HTTP POST 缓冲区大小,配置单个请求的最大大小为5G
git config --global http.postBuffer 5242880000  # 5GB = 5 * 1024 * 1024 * 1024

# 调整 HTTP 连接超时时间,避免大文件传输超时
git config --global http.lowSpeedLimit 0
git config --global http.lowSpeedTime 999999

# 增加内存缓存
git config --global core.compression 0
git config --global pack.windowMemory 1g
git config --global pack.packSizeLimit 1g
git config --global pack.threads 1

git add .
git commit -m "Add large file with LFS"

# 验证大文件能否推送成功
git push origin


网站公告

今日签到

点亮在社区的每一天
去签到