Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git LFS - how to track multiple file types with one command

Tags:

git

git-lfs

I see this command listed on the Git LFS website and documentation:

git lfs track "*.psd"

I have several file types in my project that I want to track with LFS, and will want to track all these same file types in future projects. I would like to be able to paste a single command to track all these extensions, is this possible?

like image 472
J Garcia Avatar asked Sep 21 '17 02:09

J Garcia


People also ask

What is Git LFS smudge?

In git lfs terms, 'smudge' is the process of getting the actual data for the pointers that are stored locally. By installing git lfs with the --skip-smudge option, you are setting the filter smudge = git-lfs smudge --skip -- %f in the global . gitconfig file in your home directory.

Does Git LFS Store history?

You should use Git LFS if you have large files or binary files to store in Git repositories. That's because Git is decentralized. So, every developer has the full change history on their computer.


2 Answers

After some experimentation I found this was doable by providing multiple arguments:

git lfs track "*.jpg" "*.png"

This will track both jpg files and png files

like image 55
J Garcia Avatar answered Sep 25 '22 23:09

J Garcia


I figured out a trick that allows you to store the trackings in a file, which is way easier to manage for bigger projects.

Step 1: Create a text file a list of your trackings, like this:

"*.jpg"
"*.png"

I named mine .gitlfstracks

Step 2: Bulk import trackings from that list file, like this:

cat .gitlfstracks | xargs git lfs track

cat - prints a file to screen

| - redirects the output to another application

xargs - Runs a command over each line of an input

git lfs track - The standard command to track a file

Here is my current list, fyi: https://gist.github.com/bdombro/a1883d8a2cd0938ef798147ba66ecc00

like image 20
bdombro Avatar answered Sep 24 '22 23:09

bdombro