Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I commit media files to my github repo?

Tags:

git

github

I would like to start using github to store my projects but I'm sort of confused about what to do with my media files. Many of the projects I have been working on are single page web applications that have a heavy use of graphics that make my projects look nice. I'm torn because if I commit and push the projects without any graphics anyone looking at my code (a possible employer) might get confused and think the project is visually ugly or worse, will find broken images everywhere since I gitignored those image files. However, if I commit and push the graphics it seems like this might be viewed as not a best practice and would bloat up my repository. I also tried doing this with git pages once and was really confused about what to do with my graphics.

Most of the projects I've seen on github don't seem to be web applications but are more often than not plugins and libraries so I really don't have a clue what other people are doing about this problem. Is there any standard or best practice way of dealing with git files that are images?

like image 567
Allan Socks Avatar asked Mar 18 '23 03:03

Allan Socks


1 Answers

In general, since Git tracks content (any content), it does not care about what you add to the repository. Whether it’s text files (e.g. source files), compiles binaries or other binary assets like images. Internally, Git handles all those in the same way.

You should think about whether those graphics are part of the repository or not. The way you are describing it, it seems that they indeed are part of the project since the other files depend on them. Furthermore, they cannot be created from the files already present in the repository (e.g. compiled binaries are usually not included since the repository contains the source to compile them).

As for “bloat”, yes, binary files are usually larger than text documents. As such, having many binary files in a repository can quickly increase the size of a repository. But they don’t have an extra impact compared to text files. What applies to text files also applies to binaries: Since Git only stores each content of a file once (regardless of its type), a file that stays the same throughout the history will only be stored once. So especially if your graphics are somewhat constant (i.e. you are not changing them all the time), then they will absolutely not end up “bloating up” your repository.

And again, if they are part of the project, they probably should be part of the repository.

like image 61
poke Avatar answered Mar 20 '23 17:03

poke