I think it’s generally agreed upon that large files that change often do not belong while small files that never change are fine. But there’s still a lot of middle ground where the answer is not so clear to me.

So what’s your stance on this? Where do you draw the line?

7 points

hiss The point of source control is keeping a history of the code that produces binary artifacts. For convenience’ sake or because of some wild project-specific constraints people can do all kinds of things but IMO binaries in source control are yucky yucky bad bad bad.

permalink
report
reply
5 points

I agree that the repository should only contain source files, not the output of the build process. However, in some cases (like icon images) the source files may be binary. I think small binaries that are required to build and/or run the software, and that are not an output of any build process, do make sense to put in the repository.

permalink
report
parent
reply
-1 points

I’d rather just use SVGs for the icons.

permalink
report
parent
reply
4 points

That’s not really responding to their point. Are you saying that there are no project resources that aren’t (or couldn’t be) encoded as text representation in any conceivable project that is stored in a git repo?

I agree with your general point. I’m just curious if you have some unique project pattern techniques that allow you to draw such a hard line so confidently.

permalink
report
parent
reply
2 points

Never do this.

Git is all about tracking changes over time which is meaningless with binary files. They are bloat for your repo, slowing down operations. Depending on the repo, they are likely to change from CI with every commit. That last one means that every commit turns into 2 commits btw. They are can ruin diffs. I could go on for a long time here.

There are basically 0 upsides. Use an artifact repository instead!

permalink
report
reply
6 points

Git is all about tracking changes over time which is meaningless with binary files.

Utter codswallop. You can see the changes to a PNG over time. Lots of different UIs will even show you diffs for images.

Git can track changes to binary files perfectly well. It might not be great at dealing with conflicts in them but that’s another matter.

The only issue is that binary files tend to be large, and often don’t compress very well with Git’s delta compression. It’s large files that are the issue, not binary files. If you have a 20 kB binary file it’s going to be absolutely fine in Git. Likewise a 10 GB CSV file is not going to be such a good idea.

permalink
report
parent
reply
9 points

If it’s a build artifact, put it in a registry. If it’s resource type files, Git LFS can be used if it’s not an absolute ton.

permalink
report
reply
2 points

This. If the file can be generated from the repository it should not be put inside it, but if you need it to build the project it should (unless it is an easy to install external dependency that should be declared in a Readme file).

permalink
report
parent
reply
3 points

I’ll go to quite a bit of effort to avoid them. Arguably too much effort, but I often find that the path that avoids them is also useful in other ways.

For example, for a personal project, I automated rendering a PNG fallback icon from an SVG, so now I can have as many different resolutions as I want and don’t need to manually update them, if I want to tweak the icon.

I’d also like to publish a screenshot of the project. The simple solution is to check a PNG into the repo and link it in the README.md. But what would be a lot nicer, is to set up a project webpage, which with Codeberg Pages isn’t even that much effort, but I would have less motivation to do it otherwise.

permalink
report
reply
10 points

The main downside is Git downloads all history by default, and so any large files will bloat the download for people cloning your repo forever. It isn’t about binary vs text. It’s just the size that matters.

permalink
report
reply

Git

!git@programming.dev

Create post

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Resources

Rules

  1. Follow programming.dev rules
  2. Be excellent to each other, no hostility towards users for any reason
  3. No spam of tools/companies/advertisements. It’s OK to post your own stuff part of the time, but the primary use of the community should not be self-promotion.

Git Logo by Jason Long is licensed under the Creative Commons Attribution 3.0 Unported License.

Community stats

  • 57

    Monthly active users

  • 217

    Posts

  • 904

    Comments