79
  • 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?
Teymour
  • 1,832
  • 1
  • 13
  • 34
prosseek
  • 182,215
  • 215
  • 566
  • 871

4 Answers4

69
  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.
jpaugh
  • 6,634
  • 4
  • 38
  • 90
Amber
  • 507,862
  • 82
  • 626
  • 550
  • 8
    Shouldn't this answer include a recommendation to _not_ use Git to store binaries? Git was explicitly designed for text storage, not binary. There are other tools which are better at archive management, i.e. NuGet, Maven, Artifactory, etc. – skitheo Mar 20 '18 at 23:53
  • 2
    @skitheo I would've liked a more nuanced answer as well and particularly something about chance of things blowing up – Benny Bottema Jul 19 '19 at 10:18
29

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
Bob Stein
  • 16,271
  • 10
  • 88
  • 101
Alexandre Mazel
  • 2,462
  • 20
  • 26
5
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.

SimonT
  • 2,219
  • 1
  • 18
  • 32
Guillaume Lebourgeois
  • 3,796
  • 1
  • 20
  • 23
-4

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

ashish
  • 361
  • 3
  • 8