Skip to content

Instantly share code, notes, and snippets.

@tuxBurner
Created December 12, 2016 15:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxBurner/aba45fbba9f76736fc48d65c0e7b4805 to your computer and use it in GitHub Desktop.
Save tuxBurner/aba45fbba9f76736fc48d65c0e7b4805 to your computer and use it in GitHub Desktop.

How to migrate an existing repo to a lfs repo.

The tool can be found here.

https://github.com/bozaro/git-lfs-migrate/releases

I recommend to migrate an existing repo to a new repo with lfs support activated and delte the old one afterwards.

Requirements

Java8 needed check with:

java -version

check for the line

java version "1.8.0_111"

Download latest version and extract it

Check for latest version at: https://github.com/bozaro/git-lfs-migrate/releases It was 0.2.4 when I was using it

cd ~
wget https://github.com/bozaro/git-lfs-migrate/releases/download/0.2.4/git-lfs-migrate.zip
unzip git-lfs-migrate.zip -d git-lfs-migrate

Now we have the git-lfs-migrate tool installed under the users home directory: ~/git-lfs-migrate/

Activate lfs support in your git repo

To get lfs working, make sure you activate lfs support in your repo. In this example this would be: git@github.com:example/example-converted.git

Using the tool

Clone/Mirror the repo you want to migrate.

Clone the repo you want to migrate with following git command. Replace the url with the one of repository you want to migrate.

ATTENTION: This can take a while, grab some coffee on large repos :)

git clone --mirror git@github.com:example/example.git

Convert the repo

java -jar ~/git-lfs-migrate/git-lfs-migrate.jar \
     -s example.git \
     -d example.git-converted.git \
     -g  git@github.com:example/example-converted.git \
     "*.rpm" \
     "*.jar"

The parameters are the following:

  • -s is the source repo
  • -d is the destination repo
  • -g is the url to the lfs git repo / you can add the origin later and leave this parameter out.
  • *.rpm and *.jar are added to the .gitattributes as files to handle with the lfs

To get a full list of parameters call the following command:

java -jar ~/git-lfs-migrate/git-lfs-migrate.jar --help

Push the migrated repo to the server

git push --mirror git@github.com:example/example-converted.git

Done :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment