You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

本地大体积Git仓库如何单独推送提交中的子文件夹?

How to Push Subfolders Individually in a Large Git Repository

Got it, let's break this down simply—since your 30GB dataset is too big to handle all at once, you can split the process into smaller chunks by committing and pushing each subfolder individually. Here's exactly how to do it:

Step 1: Prepare your repository (if not already done)

If you haven't initialized your local Git repo yet, start with:

git init
git remote add origin "your-github-repo-url"

(Skip this if you've already run these commands.)

Step 2: Commit and push each subfolder one by one

For each subfolder (let's use dataset-folder-1, dataset-folder-2 as examples):

  1. Stage only the target subfolder:

    git add dataset-folder-1/
    

    The trailing slash ensures you're adding all contents of the folder, not just the folder itself (though Git handles this either way, it's a clear habit to form).

  2. Commit the staged folder with a descriptive message:

    git commit -m "Add dataset subfolder: dataset-folder-1"
    

    Using specific messages helps track which parts of the dataset were added when.

  3. Push this single commit to GitHub:

    git push origin master
    

    This will only send the contents of the subfolder you just committed—no need to process the entire 30GB at once.

Repeat these three steps for every subfolder in your repository.

Important Notes

  • If you accidentally ran git add . (staged all files) already, undo the staging first with:
    git reset
    
    This clears all staged changes so you can start staging individual folders.
  • If your remote repo already has existing content, you may need to run git pull origin master before pushing to avoid conflicts (though this shouldn't be an issue if you're setting up a new repo).
  • If even individual subfolders are still too large (e.g., 10GB each), consider using Git LFS (Large File Storage) to handle large files more efficiently—but that's a separate workflow. For now, splitting by subfolders should solve your laptop crashing issue.

内容的提问来源于stack exchange,提问作者Atena

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 06:42:59