Jophen
Jophen

Reputation: 31

How to run git lfs automatically after repo sync

We started to use git lfs recently, but many team members fogot to run git lfs after repo sync. Is there any way could run git lfs after repo sync automatically?

Upvotes: 3

Views: 5397

Answers (3)

Alan Mimms
Alan Mimms

Reputation: 703

There's a faster way. If you only run git lfs pull on directories that need it, it saves time for big repository trees.

#!/bin/bash
# Walk the entire tree starting at $PWD and find all directories
# containing `.lfsconfig` file that says it's a Git clone
# directory that uses Git-LFS. For each such directory, do `git lfs
# pull`.
grep -l 'merge=lfs' $( find $PWD -name .lfsconfig ) /dev/null | while IFS= read -r line; do
    dir=$(dirname $line)
    echo $dir
    ( cd $dir ; git lfs pull )
done

Upvotes: 1

Apparently with new version of repo tool you can initialize it using --git-lfs option

repo init -u <git_url> --git-lfs

Please correct me

Upvotes: 3

As far as I know there is no solution for this without modify the repo tool, but you always can create an alias (in GNU/Linux) in the file ~/.bash_aliases or ~/.bashrc:

alias repo-lfs="repo sync && repo forall -c git lfs pull"

Then source the file source ~/.bash_aliases and instead of using repo sync, use the repo-lfs command.

Upvotes: 6

Related Questions