@kit3bus
Lars Schneider
Autodesk Inc.
Git and Git LFS
contributor
Technical Lead for
Git at Autodesk
Slide 3
Slide 3 text
@kit3bus
• Best known for AutoCAD
2D and 3D computer-aided design
• 33 years in business
• 4000 engineers, hundreds of
products, terabytes of code and
asset data
Lars Schneider
Autodesk Inc.
Slide 4
Slide 4 text
@kit3bus
Architecture,
Engineering &
Construction
Image by Dave Tyner, Autodesk Plant 3D - P&ID
Slide 5
Slide 5 text
@kit3bus
Manufacturing
Slide 6
Slide 6 text
@kit3bus
Media &
Entertainment
Slide 7
Slide 7 text
@kit3bus
3D Printing
"Future of
Making
Things"
Image courtesy of Local Motors Inc.
Slide 8
Slide 8 text
@kit3bus
Git Git LFS
+
Slide 9
Slide 9 text
@kit3bus
Why are
large files
a problem?
All history is local.
Good for source files.
Problem for large files.
Slide 10
Slide 10 text
@kit3bus
Elephant-Video.mp4
Why are
large files
a problem?
Slide 11
Slide 11 text
@kit3bus
What files are
not suited
for Git?
Files that do
not compress well and
change frequently.
...
Slide 12
Slide 12 text
@kit3bus
Mon Tue Wed
What files are
not suited
for Git?
Files that do
not compress well and
change frequently.
Slide 13
Slide 13 text
@kit3bus
Example:
Git repo
with large files
code
code
Git Repo
master
code
code
301MB
code
code
Slide 14
Slide 14 text
@kit3bus
Git LFS
to the rescue!
git lfs track "*.mp4"
Slide 15
Slide 15 text
@kit3bus 1 MB
Example:
Git LFS repo
with large files
master
LFS Server
LFS
Ptr
code
Git LFS Repo
LFS
Ptr
code
code
code
code LFS
Ptr
code
Slide 16
Slide 16 text
@kit3bus 1 MB
Example:
Git LFS repo
with large files
master
LFS Server
LFS
Ptr
code
LFS
Ptr
code
code
code
code LFS
Ptr
code
Git LFS Repo
Clone
@kit3bus
What do we
use Git LFS
for?
Integration Test Data
(3D Models, ...)
Auxiliary Data
(Documentation, Images,
Videos, ...)
Build Artifacts
(not recommended)
Slide 20
Slide 20 text
@kit3bus
DEVELOPER
MIGRATOR
ADMINISTRATOR
- Git LFS -
What have we learned?
Slide 21
Slide 21 text
@kit3bus
Migrator
Slide 22
Slide 22 text
@kit3bus
Migration
Process
1
Identify an engineer with
deep code knowledge
Create a "demo" migration
on Git migration server
Iterate on "demo" migration
until repo and CI are OK
Ask broader team to "play"
with the "demo" migration
Perform migration on Git
production server
2
3
4
5
Slide 23
Slide 23 text
@kit3bus
How to
migrate?
+
git-svn / git-p4 / git-tfs ...
git filter branch / git-lfs-migrate
Slide 24
Slide 24 text
@kit3bus
How to
migrate?
+
git-p4
git-svn / git-p4 / git-tfs ...
git filter branch / git-lfs-migrate
Slide 25
Slide 25 text
@kit3bus
Git LFS
migration
gotchas
Discard large file
history
1998 2007 2016
code code code +
+
+
@kit3bus
Mon Tue Wed
Teach why
"Large" files
are a problem!
Files that do
not compress well and
change frequently.
Slide 30
Slide 30 text
@kit3bus
Files smaller than
500kb are OK.
Rule of
Thumb
Teach why
"Large" files
are a problem!
Slide 31
Slide 31 text
@kit3bus
git lfs track "*.png"
How to track
Git LFS files?
Slide 32
Slide 32 text
@kit3bus
git lfs track "*.lfs.*"
e.g. /images/elephant.lfs.png
How to track
Git LFS files?
Slide 33
Slide 33 text
@kit3bus
git lfs track "/big/*"
e.g. /big/elephant.png
How to track
Git LFS files?
Slide 34
Slide 34 text
@kit3bus
git lfs track "/xxl.png"
How to track
Git LFS files?
Slide 35
Slide 35 text
@kit3bus
Less than 1000
files in LFS are OK.
Rule of
Thumb
How to track
Git LFS files?
Slide 36
Slide 36 text
@kit3bus
Less than 1000
files in LFS are OK.
Rule of
Thumb
How to track
Git LFS files?
https://autode.sk/git-filter
"Git checkout for a test repo with 12k
LFS files on Windows takes 57 seconds
instead of 55 minutes!"
Git 2.11 + GitLFS 1.5
Slide 37
Slide 37 text
@kit3bus
git lfs track "*.png"
git lfs track "*.[pP][nN][gG]"
Case sensitive:
Case in-sensitive:
Git LFS
Tips & Tricks
Slide 38
Slide 38 text
@kit3bus
No line ending
conversions on
LFS files!
Git LFS
Tips & Tricks
FirstLine
SecondLine
FirstLine▯SecondLine
Windows
macOS
Slide 39
Slide 39 text
@kit3bus
git lfs clone
Git LFS
Tips & Tricks
Slide 40
Slide 40 text
@kit3bus
Setup your Git
credential helper
(or use SSH)!
Git LFS
Tips & Tricks
Slide 41
Slide 41 text
@kit3bus
Use the latest
Git / Git LFS
version!
Git LFS
Tips & Tricks
Slide 42
Slide 42 text
@kit3bus
Administrator
Slide 43
Slide 43 text
@kit3bus
How to make
sure Git LFS is
used properly?
Setup Git LFS on
all dev machines!
Enterprise Config for Git
https://autode.sk/git
LFS
Ptr
Slide 44
Slide 44 text
@kit3bus
How to make
sure Git LFS is
used properly?
"What happens in
Git, stays in Git."
Slide 45
Slide 45 text
@kit3bus
How to make
sure Git LFS is
used properly?
Rewriting history
can cause a lot of
trouble!
Slide 46
Slide 46 text
@kit3bus
How to make
sure Git LFS is
used properly?
Configure file size
limit on Git server!
Slide 47
Slide 47 text
@kit3bus
How to make
sure Git LFS is
used properly?
Configure file size
limit with local
Git pre-commit
hooks!
Slide 48
Slide 48 text
@kit3bus
How to make
sure Git LFS is
used properly?
Initially, perform
Git LFS usage reviews.
Slide 49
Slide 49 text
@kit3bus
Takeaways
• Git LFS works at scale
• Use the latest Git/Git LFS versions
• Automate Git LFS setup
https://autode.sk/git
• Use fast clone command
git lfs clone
• Use smart tracking patterns
git lfs track "*.lfs.*"
• Reject large files in Git