git:什么是树内的提交对象?

问题描述

gitmod上工作时,我注意到当我停止使用旧的root_tree时,它不会被丢弃。跟踪发生了什么事之后,我注意到一棵树中有一个不是斑点或另一棵树的对象。这是一个commit对象。这是来自git的仓库:

$ git ls-tree v2.28.0 | grep sha1col
160000 commit 855827c583bc30645ba427885caa40c5b81764d2  sha1collisiondetection

我需要添加对此的支持,以便对其进行正确的管理,但是我想知道它代表什么。因为我试图获取有关该对象的信息,但不在我的仓库中:

$ git cat-file -p 855827c583bc30645ba427885caa40c5b81764d2
fatal: Not a valid object name 855827c583bc30645ba427885caa40c5b81764d2

解决方法

那是一个子模块。您可以看到路径(sha1collisiondetection)在存储库根目录的.gitmodules文件中建立了索引:

[submodule "sha1collisiondetection"]
    path = sha1collisiondetection
    url = https://github.com/cr-marcstevens/sha1collisiondetection.git
    branch = master

子模块存储库将包含在其提交中 855827c583bc30645ba427885caa40c5b81764d2。如果您git submodule update那个子模块,您将看到它获取了该提交。

Submodule path 'sha1collisiondetection': checked out '855827c583bc30645ba427885caa40c5b81764d2'

在该路径内,您可以cat-file进行提交。

% git cat-file -p 8558
tree c963fb3e40e0b9a031ffbab4f2f06bfbcc8527b7
parent 16033998da4b273aebd92c84b1e1b12e4aaf7009
author Michael Osipov <michael.osipov@siemens.com> 1557389728 +0200
committer Marc Stevens <cr-marcstevens@users.noreply.github.com> 1557396519 +0200

Detect endianess on HP-UX

HP-UX is not properly detected and classified as little endian. Add test macro
for HP-UX to make it big endian.