|
|
|
|
|
by mtdewcmu
4574 days ago
|
|
>I've never looked at .git/logs, but it looks like that is used by the `git reflog` command. It's basically a history (or log) of every commit that a particular reference has pointed to[1]. For example, I cloned the git source code: I think it's more or less the DAG represented as an adjacency list. I'd have to think a bit about why there is a separate log file for each branch. It seems that there's some redundancy in doing that, and I'm wondering what the advantages and disadvantages are of splitting the history up in that way. >It's also of note that branches are referred to as 'references' too, hence storing them under `.git/refs/`. I've developed a loathing of excessive hierarchies/trees, so I'd rather see them flattened in a single directory. But that makes sense. >See: http://stackoverflow.com/questions/5290444/why-does-git-hash.... That's a good link. What's in an object? If an object corresponds to a commit, then it must aggregate data about changes to multiple files. |
|
Think of each branch as a pointer. Then realize that you can make that pointer point anywhere on the DAG, even to parts of the DAG that have no connection to each other. The `reflog` is a (local, non-comprehensive) history of where that pointer has pointed. That's why there is a separate log for each branch. I guess that technically they could have a single log file and add another field to specify the branch, but using the same directory tree structure as under .git/refs/ makes the mental model simpler (and probably a performance improvement not to have to parse the reflog for every branch just to see the reflog for one branch).
> I've developed a loathing of excessive hierarchies/trees, so I'd rather see them flattened in a single directory. But that makes sense.
I'm not sure what branches living under .git/refs has to do with excessive hierarchies/trees. There are enough things stored in the .git directory, that if you mashed them all together it wouldn't make any sense.
> What's in an object?
If you really care to dive deeper, you can check objects here: https://github.com/git/git/blob/master/object.h
You can get a shorter version towards the bottom of the git manpage (e.g. `man git`):