Hacker News new | ask | show | jobs
by hongsy 1900 days ago
If commits are snapshots:

- say i have a repo with one file, a big 100MB csv with millions of lines.

- i change one line in the CSV for one commit.

- repeat multiple times in many many commits.

- how big will the repo be?

1 comments

i convinced myself that commits are snapshots by doing the following:

    # generate a 100M text file
    base64 -b 76 /dev/urandom | head  -c 100000000 > file.txt
    git add . && git commit -m "1"
    
    # remove first line and add a new line to bottom
    tail -n +2 file.txt > tmp && rm file.txt && mv tmp file.txt && base64 -b 76 /dev/urandom | head -n 1 >> file.txt
    git add . && git commit -m "2"
    
    # repeat
    tail -n +2 file.txt > tmp && rm file.txt && mv tmp file.txt && base64 -b 76 /dev/urandom | head -n 1 >> file.txt
    git add . && git commit -m "3"
    ...

    du -sh . # a very big folder
each of the commits are almost 80M big in the git folder. if you run `du -h .` you can see how git stores each object individually (80M big)