2

I have a github project where my application manages data in binary files. I want to have git automatically add these files in each commit and replace using the local version. All my binary files have a unique file extension that I specify and range from 60bytes to 10kb

How can I specify this behavior if possible?

edit 1:

I have two computers with git and have the same repository. I push my commits from one computer and the changelog shows that everything uploaded properly except my binary files. I used git pull on my second computer and both say that they are up-to-date however my binary files are not the same across these two devices

edit 2:

  • Git can handle binary files, add and commit them as normal. Is there something specific you're looking for? Maybe the answers to ["Is Git good with binary files?"](https://stackoverflow.com/questions/4697216/is-git-good-with-binary-files) will help. – Schwern Feb 01 '17 at 05:14
  • "I want to have git automatically add these files in each commit and replace using the local version." Do the files change often? – Code-Apprentice Feb 01 '17 at 05:27
  • yes. the files change often enough – BreadMoirai Feb 01 '17 at 05:33

3 Answers3

0

I usually use git add . from the root folder before doing my git commit command. This ensures that everything that was modified gets committed to your local repo. Note that I used a period there; the dot

merlin2011
  • 71,677
  • 44
  • 195
  • 329
J. Laderoute
  • 313
  • 2
  • 13
  • but git can't tell if a binary file has been modified – BreadMoirai Feb 01 '17 at 05:02
  • @DreadMoirai, If it isn't modified, why do you care? If it is modified, this command will add it. – merlin2011 Feb 01 '17 at 05:09
  • @DreadMoirai Git can tell if a binary file has been modified. Providing a sensible diff is harder, but possible. Are you seeing behavior that makes you say it can't? – Schwern Feb 01 '17 at 05:12
  • The question is asking because i don't know how to add such behavior – BreadMoirai Feb 01 '17 at 05:15
  • @DreadMoirai, See Schwern's comment. By default, git is perfectly capable of capturing changes in binary files. If it doesn't for you, I'd recommend looking at your git configuration files. – merlin2011 Feb 01 '17 at 05:17
  • @DreadMoirai, git commit won't commit anything that hasn't been staged. One would use the git add command to stage something and then git commit will commit it to your local repo. – J. Laderoute Feb 01 '17 at 05:18
  • i use the `git add .` and it tells me that there's nothing to commit – BreadMoirai Feb 01 '17 at 05:42
0

but git can't tell if a binary file has been modified

If you have a binary file with a specific extension which is ignored by Git when it changes... check if it is not ignored.

git check-ignore -v -- my-binary-file

If it is ignored from an IDE, check if they have not their own .gitignore list.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

Thanks for the help everyone. I compare the files online and it turns out that git was working perfectly. It turns out that i need to update my gradle settings as i was reading a cached version of the file