git 什么是子项目提交?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21088781/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 17:34:11  来源:igfitidea点击:

What is a subproject commit?

gitgithub

提问by Connor Leech

I'm trying to add the Laravel files to a Github repo.

我正在尝试将 Laravel 文件添加到 Github 存储库。

I ran

我跑了

$ git clone https://github.com/laravel/laravel.git

$ git clone https://github.com/laravel/laravel.git

The files show up fine locally but do not show up when I push to github:

这些文件在本地显示良好,但在我推送到 github 时不显示:

enter image description here

在此处输入图片说明

The commit shows:

提交显示:

enter image description here

在此处输入图片说明

How can I add the laravel files to my github repo? Also, what is a subproject commit?

如何将 Laravel 文件添加到我的 github 存储库?另外,什么是子项目提交?

采纳答案by VonC

A submodule commit is a gitlink, special entry recorded in the index, created when you add a submodule to your repo;

子模块提交是一个gitlink,它是记录在 index 中的特殊条目,在您将子模块添加到存储库时创建;

It records the SHA1 currently referenced by the parent repo.

它记录父存储库当前引用的 SHA1。

A git submodule update --initis enough to populate the laravel subdirectory in your repo.

Agit submodule update --init足以填充您的 repo 中的 laravel 子目录。

Once it is filled, note that your submodule repo is in a detached HEAD mode.

填满后,请注意您的子模块 repo 处于分离的 HEAD 模式

As shown here, when switching branches in the parent repo, your submodule gitlink will change accordingly, but your submodule content won't change until you make again a git submodule update (after the git checkout)

如这里所示,当在父仓库中切换分支时,您的子模块 gitlink 将相应更改,但您的子模块内容不会更改,直到您再次进行 git 子模块更新(在 之后git checkout

回答by Chris

It means the repository uses Submodules.

这意味着存储库使用Submodules

To pull down the Laravel code, try

要下拉 Laravel 代码,请尝试

git submodule init
git submodule update

Submodules are notoriously prickly; I recommend reading up on them before working too much on a project that uses them. The link above should be a good starting point.

子模块是出了名的多刺;我建议在对使用它们的项目进行过多工作之前先阅读它们。上面的链接应该是一个很好的起点。