Search code examples
imagegithubzip

Image files corrupted in ZIP downloaded from GitHub


The linked repository has several images that look fine on GitHub, such as this jpg image or this png image. However, when I download a ZIP file of the repository and unzip it in my Windows 10, all the image files are corrupted - their size becomes only 1 KB! How can I correctly download this repository?


Solution

  • TL;DR

    In a terminal which has git installed, just run this

    git clone -b <branch-name> --depth=1 https://github.com/erelsgl-at-ariel/gamedev-5780-code
    

    Replace <branch-name> with the branch name you want to download the zip for.


    The repository you have linked uses Git LFS1 to store binary files. The file extensions stored in such format can be found in the .gitattributes file. When you download the zip2 file only pointer files representing the binary files are generated.

    You can also identify if a file is managed using LFS in GitHub if you see this :

    LFS

    You should be able to get the images using this link format :

    https://media.githubusercontent.com/media/user_name/repository_name/branch_name/file_name

    An example for this jpg image would be : https://media.githubusercontent.com/media/erelsgl-at-ariel/gamedev-5780-code/master/02-collisions/Assets/Images/stars-background.jpg

    To get all the LFS files, you need to clone the repository using git.

    git clone <repo-link>


    1Read more about Git LFS in Github here

    2Read more on LFS files not being included in zip here