先装 Git LFS,再按后缀声明要托管的文件。
track 会写进 .gitattributes,这个文件必须提交。
已在历史里的大文件,用 migrate import 重写。
重写会改掉所有提交号,动手前先通知同事。
推完让每人重新 clone,别在旧库上直接 pull。
git lfs install
# 按后缀声明,规则写入 .gitattributes
git lfs track "*.psd" "*.zip" "*.mp4"
git add .gitattributes
git commit -m "chore: 启用 LFS 托管大文件"
# 已进历史的大文件:重写历史,转成指针文件
git lfs migrate import --include="*.psd,*.zip" --everything
# 强推前先看本地与远端差异,避免盖掉别人提交
git push --force-with-lease origin main
# 检查接管情况
git lfs ls-files
git lfs ls-files --all | head
THE END






暂无评论内容