Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrate from old LFS repo to new LFS repo?

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?

like image 430
tuchk4 Avatar asked Nov 01 '16 19:11

tuchk4


People also ask

What is migrate LFS git?

Rewrite commit history using git lfs migrate This does shrink the Git repository size but since the migrated files (blobs in Git) are changed from the file content to an LFS pointer, you end up with new commits being created and thus new commit hashes.

How do I clone a git repository LFS?

Once Git LFS is installed, you can clone a Git LFS repository as normal using git clone . At the end of the cloning process Git will check out the default branch (usually main ), and any Git LFS files needed to complete the checkout process will be automatically downloaded for you.


2 Answers

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

like image 188
max630 Avatar answered Oct 13 '22 00:10

max630


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

like image 20
Andy Avatar answered Oct 13 '22 00:10

Andy