I am reading about git objects: blob, tree, commit, tag. In order to have a better understanding of how git works, I tried some low level command like write-tree
and commit-tree
.
mkdir test; cd test
--> git init
git add file
. I can see a blob and tree object are generated in .git/objects
git write-tree
to print the current treeIDgit commit-tree treeID -m "commit a tree"
to commit this tree. After this operation, a commit object is generated and I can see it does contain author, date, etc. However, I can't check my commits using git log
, the error is : fatal: bad default revision 'HEAD'
. After above operations, when I run git status
, I see the file is still in the index waiting for commit. What is the use of commit-tree
and what's the difference between commit-tree
and `commit'?
tree — A tree object contains references to other blobs or subtrees. commit — A commit object contains the reference to another tree object and some other information(author, committer etc.) tag — A tag or a tag object is just another reference to a commit object and just makes for easier referencing.
git-commit-tree is a low level command which commits a single tree object but does not perform any of the follow-up reference and Head work that git-commit does.
– Git commits are local meaning they are recorded only on the machine on which the commits actually occur. The “git commit” command is used to tell Git to save your changes to the local repository and you have to specifically tell Git which changes you wish to include in a commit before using the “git commit” command.
Commit - committing is the process which records changes in the repository. Think of it as a snapshot of the current status of the project. Commits are done locally. Push - pushing sends the recent commit history from your local repository up to GitHub.
git-commit - Record changes to the repository
Stores the current contents of the index in a new commit along with a log message from the user describing the changes.
git commit "records changes to the repository"
Diagrammatic representation of git-commit
is shown here at SO
git-commit-tree - Create a new commit object
Creates a new commit object based on the provided tree object and emits the new commit object id on stdout
.
This is usually not what an end user wants to run directly. Creates a new commit object based on the provided tree object and emits the new commit object id on stdout. The log message is read from the standard input, unless
-m
or-F
options are given.
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