Home > other >  Transfer Git-LFS repository to a new one, with history
Transfer Git-LFS repository to a new one, with history

Time:01-28

So we had a remote git server, but it "burned", now I try to push to a new repository a git repository with all history, but I get a (missing) obj lfs error

I tried git lfs migrate but did a mistake and all files transform to lfs so for one time it worked but mess up all history with lfs objects and all history is "lfs add", "lfs deleted"

Now git lfs migrate works well but when I try to push it show same error (missing) PathToFile (4750fda193ad9d6cd94e7df41afb74f3379c53291515f92dbd619d99eb951069)

What can I do to push properly with all history remaining?

CodePudding user response:

Based on this answer:

That error means that your Git push contains a reference to a Git LFS object that was never uploaded to the server. (obviously).

Try to run git lfs push origin --all to upload all local Git LFS objects. Afterwards git push should work.

CodePudding user response:

I'm not really an expert of git but git lfs migrate is not for migrating your repository to a new server!

It is rather for

converting an existing Git repository to use Git LFS

In your case, however, it sounds like your repository already is using LFS so you don't want to use git lfs migrate at all.


What you rather want to do is migrate an existing local repository which uses LFS to a server.

If I understand this post correctly then you could do the following steps

git fetch --prune

See

Cleaning old references to remote branches

By default, when you do a git fetch or git pull, git will not delete the references to branches that were deleted in the upstream repository (you may view them in your .git/refs/remotes dir). We need to clean those old references before mirroring them to a new location.

To do so, run

$ git fetch --prune

This will update your references to the origin repository and also clean the stale branches reported by git branch -r.

git push --prune [email protected]:/new-location.git  refs/remotes/origin/*:refs/heads/*  refs/tags/*:refs/tags/*

See

Finally, mirroring the repository to a new location

Now we’re ready to send those updated references back to the origin repository:

$ git push --prune [email protected]:/new-location.git  refs/remotes/origin/*:refs/heads/*  refs/tags/*:refs/tags/*

Ok, what just happened here?!

We want those references inside the .git/refs/remotes/origin to be the LOCAL references in the new location. The local references there will be stored in the refs/heads dir. Same thing happens to tags.

The sign indicates that we want to overwrite any reference there may already exist.

--prune means we want to delete any reference that may exist there if we don’t have such reference in our refs/remotes/origin/* (and tags) references.

and I guess regarding LFS you would do a

git lfs push --all https:example.com/new-repository.git
  •  Tags:  
  • Related