Git 包含子项目

2019-05-18 10:14:48 阅读:17 编辑

添加子项目

 Git submodule add https://git.xmyunce.com/linson/Laravel-admin-installer.git packages/linson/Laravel-admin-installer

clone 包含子项目

packages/linson/Laravel-admin-installer 目录存在了,但是是空的。你必须运行两个命令:Git submodule init 来初始化你的本地配置文件,Git submodule update 来从那个项目拉取所有数据并检出你上层项目里所列的合适的提交:

Git submodule init
Git submodule update

注意事项

  1. 当子项目为空时,无法正确 submodule add
  2. 当出现以下内容时:
    A Git directory for 'packages/linson/linson-testing' is found locally with remote (s):
    origin        https://git.xmyunce.com/linson/linson-testing.git
    If you want to reuse this local Git directory instead of cloning again from
    https://git.xmyunce.com/linson/linson-testing.git
    use the '--force' option. If the local Git directory is not the correct repo
    or you are unsure what this means choose another name with the '--name' option.

可以手动删除。git/modules/linson-testing 目录。还要删除。gitmodules 以下的

[submodule "packages/linson/linson-testing"]
    path = packages/linson/linson-testing
    url = https://git.xmyunce.com/linson/linson-testing.git

然后重新 submodule add

  1. 若提示 'packages/linson/linson-install' already exists in the index
    Git rm -r --cached packages/linson/linson-install

    然后重新 submodule add