Search code examples
gitgit-lfs

Retrieve original files after a git clone with git lfs


I am a bit confused. I back up a project with Github.com. Because my files are too large to store them on Github.com, I am using git large file storage. Now I changed to a new computer, and performed a git clone on the repository stored remotly on Github.com. I also installed git lfs with brew and did a git lfs install in the just cloned repository. However, my large files are still "pointer files". When I run my project,it says, these files are missing.

I did a

git lfs fetch --all

which downloaded something. But where is it? How do I retrieve the files I backed up with git lfs after moving to a completly new computer with a fresh setup?


Solution

  • Run the following commands:

    # Fetch all the LFS files from the remote
    git lfs fetch
    
    # Replace the pointer files to the actual files
    git lfs checkout
    

    Now you should see that the pointer files are replaced by the original files.


    Moderator notes: You need Git LFS extension installed on your system for these commands to work. Official site: https://git-lfs.com/

    Install command for ubuntu/debian/linux-mint:

    sudo apt-get install git-lfs
    

    In absence of this, you might see an error message like: git: 'lfs' is not a git command. See 'git --help'.. As LFS is not a built-in extension in git.