0

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?

Update: I tried doing

1 git fetch --prune

2 git add --renormalize .

3 git push --prune git@example.com:/new-location.git +refs/remotes/origin/*:refs/heads/* +refs/tags/*:refs/tags/*

In the end when pushing is showing same error as (missing) PathToFIle (...)

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
Pikachu
  • 11
  • 4
  • 'but I get a (missing) obj lfs error' --- in what step? what command? – Lei Yang Jan 27 '22 at 15:56
  • @LeiYang when I try to push to empty remote repository. In general I tried prune, migrate, on local everything is fine, the problem is in pushin on remote – Pikachu Jan 27 '22 at 15:57
  • please paste your commands. – Lei Yang Jan 27 '22 at 15:58
  • `git lfs push origin develop` - are u talking about this? – Pikachu Jan 27 '22 at 15:59
  • i've never used lfs. but can you explain why you use? – Lei Yang Jan 27 '22 at 16:00
  • Because simple git can't push files more than 100mb, I have files 500mb or more – Pikachu Jan 27 '22 at 16:01
  • is it possible, to ask the git admin to transfer the entire repo(as zip file), to the new server filesystem? – Lei Yang Jan 27 '22 at 16:02
  • @LeiYang no, it was a private repository like a private server, and nothing left, only local .git. This is the problem – Pikachu Jan 27 '22 at 16:05
  • i mean, is the new remote git server owned by your IT admins? – Lei Yang Jan 27 '22 at 16:07
  • @LeiYang a private server, but use git lab system, in general yes – Pikachu Jan 27 '22 at 16:08
  • then don't need git push, just (compress your files then) use some removable media to copy to the server. – Lei Yang Jan 27 '22 at 16:09
  • Not an option, I need to fix this from my computer – Pikachu Jan 27 '22 at 16:25
  • Have you tried [this (lower section)](http://blog.plataformatec.com.br/2013/05/how-to-properly-mirror-a-git-repository/) ? – derHugo Jan 27 '22 at 16:44
  • Does this answer your question? [LFS upload missing objectt but the file is there](https://stackoverflow.com/questions/52612880/lfs-upload-missing-objectt-but-the-file-is-there) – Orace Jan 27 '22 at 17:18
  • @Orace No it doesn’t, prune didn’t work for me, and lfs push either, I searched for all stackoverflow and didn’t find anything that worked for me, this is why I asked myself – Pikachu Jan 27 '22 at 19:25
  • @Orace link doesn't mention prune but rather `git add --renormalize path/to/file` – derHugo Jan 27 '22 at 20:49
  • I don't know whether there is any solution to the problem (because the large objects *may* be irretrievable) and if so what it is, but Git itself can't help you here as it does not have the objects in question. Only LFS or backups can help. – torek Jan 28 '22 at 00:58

2 Answers2

0

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 git@example.com:/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 git@example.com:/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
derHugo
  • 83,094
  • 9
  • 75
  • 115
0

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.

Orace
  • 7,822
  • 30
  • 45