How does Git deal with binary files?

GitBinaryfiles

Git Problem Overview


  • 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?

Git Solutions


Solution 1 - Git

  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.

Solution 2 - Git

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

Solution 3 - Git

git add my-binary-file
git commit
git push

Will add your binary file; it is automatic.

Indeed, if you have 100 versions of your file it will store it (but compressed).

You can use submodules to make references to other repositories.

Solution 4 - Git

The issue is with .gitignore

The following paths are ignored by one of your .gitignore files: XXX/YYYY/Bin1_0x1d_0x0d.bin

Use -f if you really want to add them.

git add -f XXX/YYYY/*

OR

git add -f XXX/YYYY/Bin1_0x1d_0x0d.bin

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionprosseekView Question on Stackoverflow
Solution 1 - GitAmberView Answer on Stackoverflow
Solution 2 - GitAlexandre MazelView Answer on Stackoverflow
Solution 3 - GitGuillaume LebourgeoisView Answer on Stackoverflow
Solution 4 - GitashishView Answer on Stackoverflow