4

Im not sure why but something is a little screwed up on my repo and when I try to push my branch to github I get an error:

> git push
Git LFS: (0 of 1 files) 0 B / 61.99 MB
LFS upload failed:
  (missing) path/to/bigfile (50...4b)
error: failed to push some refs to '[email protected]:me/myproject'

> git-lfs ls-files
50.. - path/to/bigfile

>  git-lfs fsck
Object path/to/bigfile (50...4b) could not be checked: no such file or directory
Object path/to/bigfile (50...4b) could not be checked: no such file or directory
Moving corrupt objects to /Users/myname/.../.git/lfs/bad
rename /Users/myname/.../.git/lfs/objects/50/b6/50...4b 
/Users/myname/.../.git/lfs/bad/50...4b: no such file or directory  

Note that I don't care removing or deleting this file, it is not used anymore. (but the file is there!) I have tried to git-lfs untrack path/to/bigfile but no luck, and I can't push my branch.

How to fix this?

1
  • 1
    I don't use git-lfs and hence am not sure of details, but it looks as though this is a case where rewriting history (git rebase -i or git filter-branch) would be the right approach. The commit that uses the missing file has, apparently, not been sent upstream yet: if it had been you would't see failure here. So rewriting history to modify or discard the commit with the missing file, and any further commits that depend upon that commit, would get past that problem. But, again, I don't use git-lfs. Commented Oct 5, 2017 at 22:27

1 Answer 1

3

Recipe to fix corrupt lfs without rewrite history:

# set origin to original repo
git remote set-url origin ssh://[email protected]:7999/prod/A.git
git lfs update

# fetch lfs data from original repo
git lfs fetch --all origin

# set origin back to new repo
git remote set-url origin ssh://[email protected]:7999/prod/B.git
git lfs update 

# get missing lfs data from new repo
git lfs fetch --all origin

# push missing lfs data in new repo
git lfs push –all origin

# final check
git clone ssh://[email protected]:7999/prod/B.git
git lfs fetch --all origin
git lfs fsck 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.