File size: 733 Bytes
f413f92
413c34f
f413f92
 
 
 
413c34f
f413f92
 
 
413c34f
f413f92
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# manually add a passed list of files to the local LFS store in a parallel manner bypassing filter-process
# original final revision of this script was lost. huggingface-cli also has functionality for bypassing git-lfs.

export GIT_DIR=$(git rev-parse --git-dir)
[ -d "$GIT_DIR" ] || exit -1

parallel -i bash -vx -c '\
	sha=$(pv -c "{}" 2>/dev/tty | sha256sum | cut -d \  -f 1);\
	size=$(($(stat -c %s "{}")));\
	if (( size > 1024 )); then\
		dir="$GIT_DIR"/lfs/objects/${sha:0:2}/${sha:2:2}/;\
		mkdir -p "$dir";\
		mv "{}" "$dir"/${sha} && {\
			echo version https://git-lfs.github.com/spec/v1;\
			echo oid sha256:"$sha";\
			echo size "$size";\
		} > "{}" &&\
	git add "{}" || { mv "$dir"/${sha} "{}"; false; };\
	fi'\
	-- "$@"