Frage

Say we go for a sample run:

git init
echo -e 'hede\nhodo' > new.txt
git add new.txt
git commit -m 'commit 1'
 1 file changed, 2 insertions(+)
echo -e 'hede\n123' > new.txt
git add new.txt
git commit -m 'commit 2'
 1 file changed, 1 insertion(+), 1 deletion(-)

So I know SHA of two versions. When I look into them, I see:

git cat-file -p ad0daa422be9531700a069e6800b18c065f755bb
hede
hodo

git cat-file -p 6fbf5b80b76bbe270bb41789c34851d622ae1f63
hede
123

It seems git copied blob, but 'hede' remained redundant. I know it is not a big impact for small files but just asking: Does git optimize this into differences later on? Or is this the way what makes git efficient?

Thanks

War es hilfreich?

Lösung

As I mention in "How does git store files?", Git:

  • manages content (which is why you see 2 complete blobs)
  • stores internally delta (and achieve an high-compression level that way, though pack files)

So it is efficient when it matters (clone/push/pull), while providing easy and quick access locally.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top