What is the difference between git commit and git commit-tree
mkdir test; cd test–>
- I create a file and
git add file. I can see a blob and tree object are generated in
git write-treeto print the current treeID
git 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’?
One Solution collect form web for “What is the difference between git commit and git commit-tree”
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
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
-Foptions are given.