herrzinter
herrzinter

Reputation: 325

Clone git repo with all lfs objects

I want to make a backup of a git repo which uses lfs. Now, is a simple git clone --recursive my_awesome_repo_url sufficient or do I need to use additional commands to retrieve all lfs objects, which are necessary to checkout all branches and history correctly.

Upvotes: 3

Views: 2947

Answers (1)

bk2204
bk2204

Reputation: 76489

You need to do more than a git clone --recursive. You also need to do a git lfs fetch --all, because by default Git LFS only downloads objects which are referred to in the current checkout.

What my recommendation is is this:

$ git clone --mirror REPO-URL DIRECTORY
$ git -C DIRECTORY lfs fetch --all

By using --mirror, you clone the remote repository exactly and don't create any remote-tracking branches, so you get a more accurate backup.

Upvotes: 2

Related Questions