Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Git deal with binary files?

  • Do I have to do something to tell Git whether some files are binary (like in Subversion)? Or, can Git handle binary data automatically?
  • If I change the binary file, so that I have 100 binary revisions, will git just store all 100 versions individually in the repository?
  • What are submodules for with git?
like image 700
prosseek Avatar asked Aug 30 '10 15:08

prosseek


People also ask

How does Git manage binary files?

How Does Git LFS Work? Git LFS uses pointers instead of the actual files or binary large objects (blobs). So, instead of writing large files/blobs to a Git repository, you write a pointer file, and the files/blobs themselves are written to a separate server. Plus, with Git LFS, multiple servers can be used.

Should I commit binary files Git?

It's important to never commit binary files because once you've commit them they are in the repository history and are very annoying to remove. You can delete the files from the current version of the project - but they'll remain in the repository history, meaning that the overall repository size will still be large.

Does GIT differ from binary files?

Any binary format can be diffed with git, as long as there's a tool which converts the binary format to plain text. One just needs to add the conversion handlers and attributes in the same way.

Does Gitlab support binary files?

If you're using Git on the command line, there are different installation options available to you: Binary Packages: Up-to-date binary packages are available for Windows, Mac, Linux, and FreeBSD.


2 Answers

  1. Git can usually detect binary files automatically.
  2. No, Git will attempt to store delta-based changesets if it's less expensive to (not always the case).
  3. Submodules are used if you want to reference other Git repositories within your project.
like image 180
Amber Avatar answered Oct 19 '22 08:10

Amber


I had essentially the same problem: I wanted to git pickle files, which are binary, but git thinks they're text.

I found this chapter on Git Attributes in the Pro Git Book. So I resolved my issues by creating a .gitattributes file with this line:

*.pickle binary 
like image 35
Alexandre Mazel Avatar answered Oct 19 '22 09:10

Alexandre Mazel