Git Object Types
- Blob
- Tree
- Commit
- Annotated tag
Blob
Blob stores any files with any extensions like .txt, .html, .css, .png, .mp4 etc
Blob represents the single file in the git structure.
Tree
The tree represents the folder or directory in git.
Commit
Commit can store the different versions of the project.
Annotated tag
Annotated tag provides the persistent pointer to the commit.
The format of the git database is similar to JSON.
Hash function
- One-way function
- The same hash function will generate the same hash for the same input.
Create a git hash object from the text(no file exists)
Open a terminal with git directory → type …
echo “Hello, Git” | git hash-object --stdin -w
Create a git hash object from an existing file
Open a terminal with git directory → type …
git hash-object <file path> -w
Example:
git hash-object ../test.txt -w
git cat-file options
git cat-file -p <hash> Contents of the object
Example:
git cat-file -p b7aec520dec0a7516c18eb4c68b64ae1eb9b5a5e
Result: Hello, Git
git cat-file -t <hash> type of the object
Example:
git cat-file -t b7aec520dec0a7516c18eb4c68b64ae1eb9b5a5e
Result: blob
git cat-file -s <hash> size of the object
Example:
git cat-file -s b7aec520dec0a7516c18eb4c68b64ae1eb9b5a5e
Result: 11
Origin
The default name of the remote git repository is the origin.
Post a Comment