Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Separation Anxiety - Making the Switch to Git LFS

Separation Anxiety - Making the Switch to Git LFS

If you're starting a new project, using Git LFS is easy. For existing projects, however, converting a project can present a few challenges. In this workshop, we'll adapt an existing sample project to use Git LFS with Git's filter-branch command as well as the BFG Repo Cleaner. We'll also talk about the implications of these approaches on your project and your collaborators. Attendees should have a general understanding of Git internals and be comfortable working on the command line.

Allen Smith

April 05, 2016
Tweet

More Decks by Allen Smith

Other Decks in Technology

Transcript

  1. " # # $ % & ' # # (

    & code code Local Remote file.psd file.psd Large File Storage
  2. " *

  3. Let’s plan it out. 0 1. Go back to the

    beginning of the project history, then for every single commit: 2. Tell Git LFS to track the right files 3. Stage the updated .gitattributes file 4. Get a list of all the paths that Git LFS should manage at this point 5. For each of those paths, stop tracking the non-LFS version of the file 6. Restage the file to have LFS create a pointer file for it 7. Don’t forget to update tags!
  4. Let’s plan it out. 0 $  git  filter-­‐branch  -­‐-­‐prune-­‐empty  -­‐-­‐tree-­‐filter

     '   git  lfs  track  "*.zip"   git  lfs  track  "*.exe"   git  add  .gitattributes   git  ls-­‐files  -­‐z  |  xargs  -­‐0  git  check-­‐attr  filter  |  \   grep  "filter:  lfs"  |  sed  -­‐E  "s/(.*):  filter:  lfs/\1/"  |  \   tr  "\n"  "\0"  |  while  read  -­‐r  -­‐d  $'"'\0'"'  file;  do          echo  "Processing  ${file}"          git  rm  -­‐f  -­‐-­‐cached  "${file}"          echo  "Adding  $file  lfs  style"          git  add  "${file}"   done   '  -­‐-­‐tag-­‐name-­‐filter  cat  -­‐-­‐  -­‐-­‐all credit: @vmrob
  5. How do I use it? 0 1. Download  BGF  from

     https://rtyley.github.io/bfg-­‐repo-­‐cleaner/   2. $  git  clone  -­‐-­‐mirror  <url>   3. $  cd  your-­‐repo.git   4. $  java  -­‐jar  bfg.jar  -­‐-­‐convert-­‐to-­‐lfs  ‘*.psd,  mp4,  <etc>’   5. $  git  reflog  expire  -­‐-­‐expire=now  -­‐-­‐all   6. $  git  gc  -­‐-­‐prune=now  -­‐-­‐aggressive   7. $  du  -­‐sh  *