@kannonboyPhoto: Le Monde en Vidéo
@kannonboy
@kannonboy@kannonboyPhoto: Le Monde en Vidéo
@kannonboy
Git LFS!
Git LOB!
@kannonboyPhoto: Le Monde en Vidéo
@kannonboy
ok cool
@kannonboyPhoto: Le Monde en Vidéo
Git LFS!
TIM PETTERSEN • SENIOR DEVELOPER • ATLASSIAN • @KANNONBOY
Practical workflows with Git LFS
@kannonboy
G I T L F S
T H E P R O B L E M W I T H B I G F I L E S
T I P S F O R T E A M S
Agenda
C O N V E R T I N G Y O U R R E P O
@kannonboy
data model
@kannonboy
master
feature/JIRA-123
@kannonboy
434bb..tree
bab1e..parent
Tim P <kannonboy@…> 1455209277 -0800committer
Tim P <kannonboy@…> 1455209277 -0800author
My life is my commit message.
98ca9..
bab1e..
fad3d.. git cat-file -p 98ca9$
@kannonboy
git cat-file -p 434bb$
434bb..
98ca9..
bab1e..
fad3d..
ace23..100644 blob .gitignoredbdbd..100644 blob README.mda0bc3..040000 tree app33d33..040000 tree configb1de7..100755 blob deploy-prod.sh7011e..100755 blob deploy-staging.sh
typefilemode SHA-1
@kannonboy
434bb..
98ca9..
bab1e..
fad3d..
ace23.. 1010101
dbdbd..
a0bc3..
33d33..
b1de7..
7011e..
1010101
1010101
1010101
master
1010101
1010101
1010101
@kannonboy
98ca9..
bab1e..
fad3d..
@kannonboy
98ca9..
bab1e..
fad3d..
@kannonboy
dabad..
98ca9..
bab1e..
fad3d..
86753..
434bb..
50mb100mb150mb
@kannonboy
@kannonboy
(Large File Storage)
Git LFS
@kannonboy
dabad..
98ca9..
bab1e..
fad3d..
86753..
434bb..
$
LFS store
Git host
@kannonboy
☞
☞
☞
dabad..
98ca9..
bab1e..
fad3d..
86753..
434bb..
Git host
LFS store
git push$
@kannonboy
☞
☞
☞
dabad..
98ca9..
bab1e..
fad3d..
86753..
434bb..
git pull$
LFS store
Git host
@kannonboy
☞
☞
☞
dabad..
98ca9..
bab1e..
fad3d..
86753..
434bb..☞
☞
☞
dabad..
98ca9..
bab1e..
fad3d..
86753..
434bb..
https://git-lfs.github.com/spec/v1version
sha256:325ddfb…oid
29342295size
git cat-file -p 4749d$
4749d..
bdd12..
778aa..
@kannonboy
$ brew install git-lfs
$ git lfs install
@kannonboy
$ cat ~/.gitconfig
[filter "lfs"] clean = git-lfs clean %f smudge = git-lfs smudge %f required = true
@kannonboy
$ git lfs track “*.mp4”
$ cat .gitattributes
*.mp4 filter=lfs diff=lfs merge=lfs -text
@kannonboy
massive_video.mp4
Work tree
dev
.git/lfs/objects
Clean filter(git-lfs clean)
☞
Index
massive_video.mp4
$
.git/objects
git add
@kannonboy
$
dev
.git/lfs/objects
Smudge filter(git-lfs smudge)
Work tree
massive_video.mp4
☞
Commit tree
massive_video.mp4.git/objects
LFS Store
git checkout
@kannonboy
$ cat ~/.gitconfig
[filter "lfs"] clean = git-lfs clean %f smudge = git-lfs smudge %f required = true
@kannonboy
.git/lfs/objects
.git/objectsHosted repo
LFS store
git push / pull
@kannonboy
$ ls .git/hooks/
commit-msg.sample post-update.sample pre-commit.sample pre-push ...
@kannonboy
$ git push
Git LFS: (12 of 13 files, 1 skipped) 168.75 MB / 180.87 MB, 12.12 skipped
Counting objects: 22, done. ...
@kannonboy
$ git pull
remote: Counting objects: 3, done. ... Downloading massive_video.mp4 (38.79 MB) ... 1 file changed, 2 insertions(+)
@kannonboy
$ git clone ssh://git@bitbucke..
Cloning into ‘big_repo’ ... Downloading massive_video.mp4 (38.79 MB) ... Checking out files: 100% (13/13), done.
@kannonboy
Converting to Git LFS
☞
@kannonboy
434bb..
fad3d..
98ca9..
41222..
dabad.. 100mb150mb
ace34..☞ 150mb!?!?
@kannonboy
git filter-branch
$ git filter-branch --force --index-filter \ 'git rm --cached --ignore-unmatch big_video.mp4’ \ --prune-empty --tag-name-filter cat -- --all
DON’T DO
THIS!
@kannonboy
$ git filter—branch --prune-empty --tree-filter ' git config -f .gitconfig lfs.url “https://bitbucket.example.com/team/repo.git” git lfs track "*.mp4" git add .gitattributes .gitconfig
for file in $(git ls-files | xargs git check-attr filter | grep "filter: lfs" | sed -r "s/(.*): filter: lfs/\1/"); do git rm -f --cached ${file} git add ${file} done' --tag-name-filter cat -- --all
@kannonboy
DON’T DO
THIS
EITHER!
@kannonboy
BFG Repo-Cleaner
@kannonboy
@kannonboy
BFG Repo-Cleaner
@kannonboy
10-720x faster than filter-branch
built to kill history
Git LFS support
@kannonboy
$ git filter—branch --prune-empty --tree-filter ' git config -f .gitconfig lfs.url “https://bitbucket.example.com/team/repo.git” git lfs track "*.mp4" git add .gitattributes .gitconfig
for file in $(git ls-files | xargs git check-attr filter | grep "filter: lfs" | sed -r "s/(.*): filter: lfs/\1/"); do git rm -f --cached ${file} git add ${file} done' --tag-name-filter cat -- --all
@kannonboy
DON’T DO
THIS
EITHER!
@kannonboy
$ brew install bfg
$ bfg —-convert-to-git-lfs ‘*.{zip,mp4}’ --no-blob-protection
@kannonboy
Enable in Bitbucket
@kannonboy
Tips for teams
@kannonboyBeware merge conflicts @kannonboy
@kannonboy
…meanwhile in
@kannonboy
…meanwhile in
@kannonboyTeamwork @kannonboyTeamwork
@kannonboy
$ git lfs fetch --recent
$ git config lfs.fetchrecentalways “true”
lfs.fetchrecentrefsdays
lfs.fetchrecentremoterefs
lfs.fetchrecentcommitsdays
(default = 7)
(default = 0)
@kannonboyFetch the bare necessitiesFetch the bare necessities @kannonboy
@kannonboy
# for a build that just runs the unit tests $ git config lfs.fetchexclude Assets/**
# for an audio engineer $ git config lfs.fetchinclude Assets/Audio/**
@kannonboyGUI tools @kannonboy
@kannonboy
1. Install EGit Team Provider version 4.2+ 2. Make sure git-lfs is on your path
@kannonboy
SourceTree
@kannonboy
coming soon!Bitbucket Cloud
git-lfs.github.comdocs
github.com/github/git-lfssource
atlassian.com/bitbucketBitbucket Server
Lookingfor
more?
@kannonboy@kannonboy
Thank you!
TIM PETTERSEN • SENIOR DEVELOPER • ATLASSIAN • @KANNONBOY