I am learning about Git, and it would be great if I had a description of the mathematical structure that represents a Git repo. For instance: it's a directed acyclic graph; its nodes represent commits; its nodes have labels (at most one label per node, no label used twice) that represent branches, etc. (I know this description is not correct, I'm just trying to explain what I'm looking for.)
Within a repository, Git maintains two primary data structures, the object store and the index. All of this repository data is stored at the root of your working directory in a hidden subdirectory named .
The Git file directory is structured like a tree. It starts with a HEAD that points to the latest commit on the working branch. The HEAD will always show you where you are working from on Git Bash. Imagine you are driving and arrive at a crossroads and point your car in one direction.
A Git repository tracks and saves the history of all changes made to the files in a Git project. It saves this data in a directory called . git , also known as the repository folder. Git uses a version control system to track all changes made to the project and save them in the repository.
In Git, the repository is like a data structure used by VCS to store metadata for a set of files and directories. It contains the collection of the files as well as the history of changes made to those files. Repository in Git is considered as your project folder.
In addition to the links in Nevik Rehnel's comment (copied here per request: eagain.net/articles/git-for-computer-scientists and gitolite.com/gcs), and sehe's point that the commit graph forms a Merkle Tree, I'll add a few notes.
120000
(the file mode for a symlink), the file's "contents" are really the symlink target. Some mode value is (ab)used for submodules, but I forget which. R and W mode bits are not stored, only X bits (and even then they're ignored if the repo configuration says to ignore them).git commit --allow-empty
) it uses that empty tree. (Since the empty tree has no sub-objects, its SHA-1 hash value is a constant.)git gc
. The empty tree appears to be immune to collection. Anything in the refs/
and logs/
directories and the file packed-refs
(in .git
, or for bare repos or when $GIT_DIR
is set, wherever else) acts as a reference, as do the special names (HEAD
, ORIG_HEAD
, etc.); I'm not sure if other random files, if created in .git
and containing valid SHA-1s, would act as references, or not.git add
a file, git drops the file into the object-store and places the (non-text) SHA-1 hash into the index file. These are valid references that prevent garbage collection.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With