Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Git子模块的gitlink条目位于哪里?_Linux_Git - Fatal编程技术网

Linux Git子模块的gitlink条目位于哪里?

Linux Git子模块的gitlink条目位于哪里?,linux,git,Linux,Git,在哪里可以看到gitsubmodules(7)中提到的gitlink条目 对于工作目录位于path/to/bar/的子模块,gitlink条目应位于/path/to/bar并包含子模块提交的SHA-1哈希 $ git submodule status 139dedcb98fca8fb69d70305709783ff40316cd4 tabulous (0.5.0-2-g139dedc) 24afe922e6a05891756ecf331f39a1f6743d3d5a vim-repeat (

在哪里可以看到
gitsubmodules(7)
中提到的gitlink条目

对于工作目录位于
path/to/bar/
的子模块,gitlink条目应位于
/path/to/bar
并包含子模块提交的SHA-1哈希

$ git submodule status
 139dedcb98fca8fb69d70305709783ff40316cd4 tabulous (0.5.0-2-g139dedc)
 24afe922e6a05891756ecf331f39a1f6743d3d5a vim-repeat (v1.2-9-g24afe92)
 f51a26d3710629d031806305b6c8727189cd1935 vim-surround (v2.1-18-gf51a26d)
$ ls -la tabulous/
total 72
drwxr-xr-x  8 nlykkei  staff   256B Apr  5 17:25 ./
drwxr-xr-x  5 nlykkei  staff   160B Apr  4 12:00 ../
-rw-r--r--  1 nlykkei  staff    67B Apr  4 12:00 .git
-rw-r--r--  1 nlykkei  staff    21B Apr  4 12:00 .gitignore
-rw-r--r--  1 nlykkei  staff    18K Apr  4 12:00 LICENSE
-rw-r--r--  1 nlykkei  staff   5.0K Apr  5 17:25 README.md
drwxr-xr-x  4 nlykkei  staff   128B Apr  5 17:25 doc/
drwxr-xr-x  3 nlykkei  staff    96B Apr  5 17:25 plugin/
$ cat tabulous/.git
gitdir: ../../../../../.git/modules/vim/pack/bundle/start/tabulous
man 7 Git子模块

   ...
   Assuming the submodule has a Git directory at $GIT_DIR/modules/foo/ and a working directory at path/to/bar/, the superproject tracks the submodule via a gitlink entry in
   the tree at path/to/bar and an entry in its .gitmodules file (see gitmodules(5)) of the form submodule.foo.path = path/to/bar.

   The gitlink entry contains the object name of the commit that the superproject expects the submodule's working directory to be at.

Git记录添加的子模块内容的提交id的方式与记录添加的文件内容的blob id的方式相同,即在索引或记录的树中列出id。这是一个gitlink:您的内容在另一个提交中,如果您愿意,可以在该路径上签出。
git子模块
helper命令可以帮助您找到并解决具有该提交的repo,但它只不过是helpers,一个任意名称的抓包,用于方便地编写一到五行代码,否则您将自己完成编写

git rev-parse @:tabulous      # HEAD commit entry: "the current checkout had this here"
git rev-parse :tabulous       # index entry, "last thing added or checked out here"

git -C tabulous rev-parse HEAD   # what's actually checked out here
当然,您可以进行任何进一步的检查。通常,跟踪内容的低级版本是

git -C tabulous diff-index --quiet --cached @ || echo staged changes in tabulous
git -C tabulous diff-files -q                 || echo unstaged changes in tabulous
我不知道一个命令快速“任何未跟踪的内容在所有”检查,我认为你仍然需要ls文件和一些脚手架,例如

stdbuf -oL git -C tabulous git ls-files --exclude-standard -o  | grep -q . \
&& echo untracked, unignored files in tabulous

stdbuf -oL git -C tabulous git ls-files --exclude-standard -oi | grep -q . \
&& echo untracked, ignored files in tabulous
(stdbuf-oL的
stdbuf部分只在真正大的工作树中起作用,在工作树中,击键是值得的,以避免走到足够远的地方,从而找到一个满是名称的整个缓冲区)


请注意,单个目录作为对象存在于对象数据库中,但不存在于索引中,每次包含更改时都写入新目录是索引的目的之一,以避免每次更改都会出现新树,但在编写脚本时可以帮助您了解这一点:if“tabulous”在您的示例中,它只是一个目录而不是子模块,它没有自己的索引项(因为使该id保持最新将是索引存在时避免的不必要的开销之一)。

谢谢。文档在
path/to/bar
的树中说gitlink条目不是错误的吗?您对GITLink的解释与此不同。考虑“代码> Git LS树-RD /代码>的输出:<代码> 160000提交139DEDCB98FCA8FB69D703057097 83FF40316CD4 VIM/包/捆绑/启动/制表< /代码>。“提交”是“子模块”的同义词吗?也就是说,
git
知道对象ID引用子模块,因为它的类型“commit”(或者“commit”可以表示“submodule”的其他内容)?)不管您如何称呼它,也不管您是否使用
git子模块
帮助程序。该条目是一个提交id。这就是“gitlink”所指的:一个保存提交id而不是blob或嵌套树id的条目。但它仍然是为该路径记录、添加的id。它是使工作树与提交的内容相匹配的内容。