gpt4 book ai didi

git 添加具有深度和分支选项的子模块

转载 作者:太空狗 更新时间:2023-10-29 14:22:49 36 4
gpt4 key购买 nike

使用 git 2.4.3 (Fedora 22),我可以使用 --depth-b 选项克隆一个 repo:

$ git clone --depth 1 -b release https://github.com/adobe-fonts/source-code-pro.git fonts/source-code-pro
Cloning into 'fonts/source-code-pro'...
remote: Counting objects: 114, done.
remote: Compressing objects: 100% (113/113), done.
remote: Total 114 (delta 1), reused 105 (delta 1), pack-reused 0
Receiving objects: 100% (114/114), 7.27 MiB | 2.85 MiB/s, done.
Resolving deltas: 100% (1/1), done.
Checking connectivity... done.

理论上 git submodule add 应该支持相同的选项。不幸的是它似乎不起作用:

$ mkdir foo
$ cd foo
$ git init
Initialized empty Git repository in /spare/local/arankine/foo/.git/
$ git submodule add --depth 1 -b release https://github.com/adobe-fonts/source-code-pro.git fonts/source-code-pro
Cloning into 'fonts/source-code-pro'...
remote: Counting objects: 35853, done.
remote: Compressing objects: 100% (5932/5932), done.
remote: Total 35853 (delta 35196), reused 30018 (delta 29921), pack-reused 0
Receiving objects: 100% (35853/35853), 12.95 MiB | 3.06 MiB/s, done.
Resolving deltas: 100% (35196/35196), done.
Checking connectivity... done.
fatal: Cannot update paths and switch to branch 'release' at the same time.
Did you intend to checkout 'origin/release' which can not be resolved as commit?
Unable to checkout submodule 'fonts/source-code-pro'

此处的目的是尽量减少这些字体所需的磁盘空间,这些字体作为二进制对象分布在该存储库的 release 分支上。只有最新的二进制文件是相关的。

我不太清楚如何使这项工作有效,请指教。

最佳答案

首先添加你的子模块,不要提及分支。

然后 make your submodule track the right branch :

cd /path/to/your/parent/repo
git config -f .gitmodules submodule.<path>.branch <branch>

cd path/to/your/submodule
git checkout -b branch --track origin/branch
# if the master branch already exist:
git branch -u origin/master master

您可能需要提高深度以包含所需分支的提交部分,而不是默认主分支的提交部分。

关于git 添加具有深度和分支选项的子模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34456530/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com