Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push to new remote with LFS

A remote repository (origin @ BitBucket) got deleted. I have a local version of that project and I'm trying to recreate this repository from my local copy.

The deleted project used LFS. I have created a new empty repository on GitLab and added it as a secondary remote named "origin2".

When I try to do git push origin2 master my upload process gets stuck at Uploading LFS objects: 50% (2553/5107), 783 MB | 0 B/s

I tried to do git push origin2 master --no-verify and this worked. But if I now clone this new repository from GitLab and try to open the project I get all kinds of errors which I assume is because some files previously "handled" by LFS are missing.

Is there a way I can fully recreate the repository from my local copy?

This is how my config looks:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
[remote "origin"]
    url = [email protected]:company/project.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[lfs "https://bitbucket.org/company/project.git/info/lfs"]
    locksverify = false
[remote "origin2"]
    url = [email protected]:company/project.git
    fetch = +refs/heads/*:refs/remotes/origin2/*
[lfs "https://gitlab.com/company/project.git/info/lfs"]
    locksverify = true
like image 431
Shard Avatar asked Sep 06 '25 03:09

Shard


1 Answers

If you don't have all of the LFS objects on the original server, then you have lost data. Unlike the Git data, the entirety of the LFS data is not stored in your local repository and is typically only stored on the server.

The pre-push hook, which is skipped with --no-verify, is where LFS files are typically pushed, which is why pushing this way seems to work.

The proper way to push LFS objects to a new location is to fetch them with git lfs fetch --all and then push with git lfs push --all NEW-REMOTE. However, if you have no way to fetch the old data, then it's just gone.

like image 169
bk2204 Avatar answered Sep 09 '25 00:09

bk2204