3

I'm trying to understand how Git works.

If I were to change (add or remove) character, save and commit that change until my code is written how will the size increase as the file becomes bigger? For example, what would be the size increase difference between commits 1 to 10, 1 to 100, 1 to 1 million even?

Also, does it become slower over time to commit changes? At which nth commit does it become unfeasible?

1 Answer 1

6

You can try yourself:

#! /bin/bash
set -eu

chars=({a..z})

rm -rf git
mkdir git
cd git
git init
git config user.email [email protected]

for (( i = 0; i <= 10000 ; ++i )) ; do
    printf ${chars[RANDOM % 26]} >> a
    time git add a
    time git commit -m "Change $i"
    du -s .git
done

If it gets too slow, try running git gc or git repack.

1
  • Thank you, man, I feel stupid. You're a genius. What happens if I repack though?
    – babygirl
    Mar 21, 2019 at 6:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.