Git LFS - how to track multiple file types with on

2019-04-12 08:06发布

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?

标签: git git-lfs
2条回答
Summer. ? 凉城
2楼-- · 2019-04-12 08:54

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

查看更多
倾城 Initia
3楼-- · 2019-04-12 09:05

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

查看更多
登录 后发表回答