I have a "large" (5 mb) text file in a git repo.
If I add a character at the last line and run git add
my .git folder increases in size with approx 1 mb (which I assume is the compressed size of my 5 mb file).
The same happens for each time I edit and add.
If I run git add -p file
I get a nice diff back of just a few bytes. But anyway the large object file gets stored when I full fill the add.
Running git gc --prune=now
removes the large object files, and things still seems to work as expected.
But regularly running git gc after each add is not a good option since I use git in an automatic way on a SD-card which will wear out the card writing and deleting megabytes in that way.
So, my question(s) is
1) I am I right that this is the behavior of git? or do I misunderstand something?
2) Can I avoid this and make git only save the diff?
I have no problem trading away flexibility in restoring old changes and so on. There is no need for branching or stashing or other things that can complicate life for git.
edit Just to be clear, my problem isn't that git saves the whole file once. But that it stores the whole file for each edit. If I add 10 characters with add and commit between each character-editing, it saves the whole file (in compressed form) 10 times.