Buffalo
Buffalo

Reputation: 4052

git checkout getting ASCII file instead of binary

Installed Ubuntu 18.04 on a fresh PC and a binary file gets cloned out as a text file.

Ran command on both old and new boxes:

$ git checkout -f a8afd894150cc31cde43dbeb422183640b64dcab
HEAD is now at a8afd8941 did some stuff.

old PC:

file composer.phar
composer.phar: data

new PC:

$ file composer.phar
composer.phar: ASCII text

After seeing it fails, I installed/enabled git lfs:

$ apt-get install git-lfs 
$ git lfs install
Updated git hooks.
Git LFS initialized.

Both /root/.gitconfig and /var/lib/jenkins/.gitconfig look identical on old and new PCs.

Any ideas what's wrong?

Upvotes: 3

Views: 1878

Answers (1)

bk2204
bk2204

Reputation: 77014

The files that you have on disk are called LFS pointer files, and they're the way that Git LFS keeps track of data. If when you did the checkout, Git LFS wasn't installed or you hadn't run git lfs install already, then Git wouldn't have invoked Git LFS to check out the real large files, and it would have left the pointer files in the tree.

The easiest way to recover from this is to run git lfs pull, which will download and check out all the files in your working tree. Since you've run git lfs install, Git should invoke Git LFS the next time you switch branches, and everything should happen automatically.

For reference, the entries you're looking for in the .gitconfig files are these:

$ git config -l | grep filter.lfs
filter.lfs.clean=git-lfs clean -- %f
filter.lfs.process=git-lfs filter-process
filter.lfs.smudge=git-lfs smudge -- %f

They're automatically set up by git lfs install, but you can set them manually if that's more convenient.

Upvotes: 5

Related Questions