threads / discuss / 23353

What happens in this example case?

Subject: What happens in this example case?

## tl;dr

3 messages between Apr 6, 2010 and Apr 6, 2010.

replies: 2people: 2as markdown or json

Kārlis Repsons· Apr 6, 2010, 09:13 UTC · lore

Hi, it would be good if someone explained how is git doing things internally when:

1. mkdir dir; cd dir; git init; echo -e "A\na\nA" > file; git add .; git commit -a -m comm1

2. echo -e "A\nb\nA" > file; git commit -a -m comm2;

I want to understand how those three letters are stored in each of the two cases and how can the contents of file be recovered from .git archive, say, after git reset --hard <commit-hash>?

(is git storing just the position of change for 'b' and 'b' in the second case? why is $(git cat-file -p) showing all three letters for the respective objects in both cases?)

Eric Raible· Apr 6, 2010, 15:42 UTC · re: Kārlis Repsons · lore

Re: What happens in this example case?

Kārlis Repsons <k <at> 11.lv> writes:
> 
> Hi,
> it would be good if someone explained how is git doing things internally when:

Hi, it would be good if someone did basic research before asking such questions.

Start with http://book.git-scm.com.
Kārlis Repsons· Apr 6, 2010, 16:25 UTC · re: Eric Raible · lore

Re: What happens in this example case?

On Tuesday 06 April 2010 15:42:05 Eric Raible wrote:
Show 5 quoted lines
> Hi,
> it would be good if someone did basic research before asking such
>  questions.
> 
> Start with http://book.git-scm.com.

Thanks, silly enough I didn't see that link in the documentation page, where "Git Community Book : The git-scm.com community-built comprehensive online book" was just a headline of some kind to me...

So, as I now understand it: git stores all unique contents of a file into a blob; there is no need to descend into the previous commits to get the actual contents of a file (as I was admitting, it could happen with help of diffs).

← back to recent threads