git子模块更新-不签出?

时间:2018-10-26 21:29:19

标签: git git-submodules

我有一个git repo,其中包含一个相当大的子模块,需要在其中添加一些项目。我宁愿不克隆并检出整个工作树。

有了克隆,我可以做git clone <repo> --no-checkout,但这似乎不是此子模块的选项。那是我目前的解决方案:

git clone <remote-path-to-MySubmodule> --no-checkout
cd MySubmodule
cp path/to/files/* .
git add path/to/files/*
git commit -m <message>
git push

但是感觉submodule工作流程也应该允许这样做。

1 个答案:

答案 0 :(得分:0)

  

我宁愿不克隆并检出整个工作树

如果您希望克隆存储库,但不需要完整的历史记录,请执行浅表克隆

# --branch=<branch> Clone only specific branch 
# --depth=1 clone only the last 1 commits 

git clone <url> --branch=<branch_name> --depth=<X>   
git clone <url> --branch=master --depth=1

按照下面的注释中的要求

如何创建孤立分支?

什么是孤枝?

孤立分支是没有任何历史记录的分支。使用git checkout -b <name>将使用当前分支的完整历史记录创建分支。

使用孤立分支创建没有历史的“孤立”分支。

git checkout --orphan branch_name