git commit 和 git commit-tree 有什么区别
What is the difference between git commit and git commit-tree
我正在阅读 git 个对象:blob、树、提交、标记。为了更好地理解 git 的工作原理,我尝试了一些低级命令,如 write-tree
和 commit-tree
。
mkdir test; cd test
--> git init
- 我创建了一个文件
git add file
。我可以看到在 .git/objects
中生成了一个 blob 和树对象
git write-tree
打印当前树ID
git commit-tree treeID -m "commit a tree"
提交这棵树。在这个操作之后,生成了一个提交对象,我可以看到它确实包含作者、日期等。但是,我无法使用 git log
检查我的提交,错误是:fatal: bad default revision 'HEAD'
。
经过以上操作,当我运行 git status
时,我看到文件还在索引中等待提交。 commit-tree
有什么用,commit-tree
和`commit'有什么区别?
git-commit - 记录对存储库的更改
在新提交中存储索引的当前内容以及来自用户的描述更改的日志消息。
git commit "records changes to the repository"
git-commit
的图示显示在 here SO
git-commit-tree - 创建一个新的提交对象
根据提供的树对象创建一个新的提交对象,并在 stdout
上发出新的提交对象 ID。
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.
我正在阅读 git 个对象:blob、树、提交、标记。为了更好地理解 git 的工作原理,我尝试了一些低级命令,如 write-tree
和 commit-tree
。
mkdir test; cd test
-->git init
- 我创建了一个文件
git add file
。我可以看到在.git/objects
中生成了一个 blob 和树对象
git write-tree
打印当前树IDgit commit-tree treeID -m "commit a tree"
提交这棵树。在这个操作之后,生成了一个提交对象,我可以看到它确实包含作者、日期等。但是,我无法使用git log
检查我的提交,错误是:fatal: bad default revision 'HEAD'
。
经过以上操作,当我运行 git status
时,我看到文件还在索引中等待提交。 commit-tree
有什么用,commit-tree
和`commit'有什么区别?
git-commit - 记录对存储库的更改
在新提交中存储索引的当前内容以及来自用户的描述更改的日志消息。
git commit "records changes to the repository"
git-commit
的图示显示在 here SO
git-commit-tree - 创建一个新的提交对象
根据提供的树对象创建一个新的提交对象,并在 stdout
上发出新的提交对象 ID。
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.