coderama coderama - 6 months ago 18
Linux Question

How to "git add -all", but limit it to maximum 100 at a time?

There are about 3000 files that I need to commit to a repo. Most are images. My problem is if I do what I normally do:

git add --all


... then I can't push because the git server has various limits that it just keeps hitting. I tried adding workarounds for these limits, but the truth is, I don't normally do such big commits, so I would prefer to not change the settings.

Instead I was hoping there is a way to ONLY add the first 100 untracked files and then stop. Then I can do a "git commit" and a "git push" and all should be well with the world.

Any idea how to do this?

Answer

If you have bash available, this should work: list all untracked files, select the first 100 to pass to git add as argument.

git ls-files --others --exclude-standard | head -n 100 | xargs git add