Search code examples
gitbashunixargumentsgit-lfs

How to use git add or git lfs track A LOT of files


My directory structure is as such with lots of files with .xyz extension:

/outerdir-123
    /123456a
       abc.xyz
    /123457b
       lmn.xyz
       opq.xyz
    /999998c
       def.xyz
       ghi.xyz
       lop.xyz

When I tried to do:

git lfs track outerdir-123/**

or when I try to add the files:

git add outerdir-123/**

It throws a

-bash: /usr/local/bin/git: Argument list too long

There are around 100,000 inner directories and each directory contains 1 to 20 .xyz files.

The files are small enough (< 10MB each) so they should be able to fit into the git repository.

How to use git add or git lfs track A LOT of files and subdirectories in outerdir-123? Is that possible at all?

Should I write a script and just add/track each subdirectory individually?


Solution

  • Just use double quotes for the lfs:

    git lfs track "outerdir-123/**"
    

    And just the directory name for the add:

    git add outerdir-123