14

I am new to git-lfs, Following are the steps I configured and tried to push git-lfs

git clone git@gitlab.example.com:group/project.git copied a tar.gz lfs file from different repo to my current repo, then

git lfs install                      
git lfs track "*.tar.gz"
git add .gitattributes
git commit -m "message"

while git push origin master:

Error I am facing:

(missing) code.tar.gz (f2b4bf22bcb011fef16f80532247665d15edbb9051***)
Uploading LFS objects:   0% (0/1), 0 B | 0 B/s, done.
hint: Your push was rejected due to missing or corrupt local objects.
hint: You can disable this check with: 'git config lfs.allowincompletepush true'
error: failed to push some refs to 'git@gitlab.example.com:group/project.git'

For your reference: when I run ls .git/lfs/objects/f2/b4 I'm not able to find anything inside.

but for other tar files if I run ls .git/lfs/objects/g3/8a i am able to see c5a9a2e024875718b6377bb15a42fac872a3**** value

dejanualex
  • 3,872
  • 6
  • 22
  • 37
k4jc
  • 151
  • 1
  • 1
  • 6

2 Answers2

21

I solved it by downloading the lfs objects referenced from that specific branch:

git lfs fetch --all <remote-name> <branch-name>

it will populate the missing files .git/lfs/objects folder

A-_-S
  • 680
  • 5
  • 21
  • Oh man, you just saved my life... I was migrating from gitlab to github and this did the trick... – Junior Apr 22 '21 at 06:48
  • IMO remote/branch names aren't necessary, `git lfs fetch --all` should be enough. Anyhow...thanks for the solution! Sharing is caring ;) – Brandt Jun 28 '21 at 13:11
  • 1
    @Brandt the --all in that case refer to all files. not like as git fetch --all (which refers to all remotes) – A-_-S Jun 29 '21 at 07:43
1

If you have this problem, and the git lfs fetch --all also does not help, and you also happen to have merged across repositories, then the problem may be that you have merged some LFS files from the other repository, then deleted them, without deleting them from the local LFS cache.

Most likely, these files are then unwanted anyway, and what you want to do is ignore them, by enabling the option

git config  lfs.allowincompletepush true

which does the following:

lfs.allowincompletepush

When pushing, allow objects to be missing from the local cache without halting a Git push.

(documentation)

This option should generally make your push succeed, but you may want to be sure that you will not be missing any files by using it.

Florian Winter
  • 4,750
  • 1
  • 44
  • 69