11

There is LFS git repository hosted at Bitbucket server. Now we need to create new LFS repo and move repository there with LFS storage.

How to do this?


For example for normal repo we can do:

git remote add new NEW_REMOTE_REPO_URL 
git push —-all NEW_REPO_URL

Will LFS storage be created with all history for new repo?

tuchk4
  • 2,270
  • 5
  • 21
  • 34
  • https://github.com/bozaro/git-lfs-migrate – max630 Nov 03 '16 at 06:15
  • 1
    Though to me it seems it could have been `git-lfs fetch --all` and some `git git-lfs push ...` – max630 Nov 03 '16 at 06:16
  • 2
    as I know `git-lfs-migrate` is for converting repo that is without LFS to LFS. But for this I used BFG https://rtyley.github.io/bfg-repo-cleaner/ and seems it is much better. Here is example https://github.com/rtyley/bfg-repo-cleaner/releases/tag/v1.12.5 – tuchk4 Nov 03 '16 at 12:33
  • Ah yes, you are correct, I should have read more carefully – max630 Nov 03 '16 at 18:48

2 Answers2

16
git remote add new NEW_REMOTE_REPO_URL 
git push —-all NEW_REPO_URL

Basically yes this will do what you want, but it would fail if you don't have all lfs data cached locally. To get it you should run before your commands:

git lfs fetch --all

PS: you could also run git lfs push --all new to only push lfs data, but git push will push them also, if the pre-push hook is set up

max630
  • 8,762
  • 3
  • 30
  • 55
1

You can modify the lfs endpoint in your local repo by doing something like: git config lfs.url = "https://my_other_server.example.com/foo/bar/info/lfs"

If you need it to stick in the repository, they recommend: git config -f .lfsconfig lfs.url https://my_other_server.example.com/foo/bar/info/lfs git add .lfsconfig

See https://github.com/github/git-lfs/wiki/Tutorial#lfs-url

Andy
  • 773
  • 2
  • 6
  • 22
  • 6
    yes. But this is just change LFS server url. How to migrate existing LFS storage to new LFS storage that is attached to new repo? – tuchk4 Nov 02 '16 at 10:18