gpt4 book ai didi

git - 从 git 版本 1.9.3 开始,删除 git 子模块的方法是什么?

转载 作者:IT王子 更新时间:2023-10-29 00:31:59 26 4
gpt4 key购买 nike

自 mac 上的 git 版本 1.9.3 (Apple Git-50) 起,我如何删除 git 子模块?我正在阅读很多过时的信息,许多开发人员告诉我他们不会工作。目前的方式是什么? git deinit pathToSubModule 会成功吗?

我认为可行的步骤是 here但评论说他们不会。

让我解释一下我目前的情况以及我需要完成的工作。我已经安装了 the Quick repository并将其作为子模块添加到我的项目中。此代码已 checkin ,其他人正在使用它。我现在需要做的是fork 相同的 Quick 存储库并将其托管在我公司拥有的更安全的 github 上(因此是一个完全不同的私有(private) github)。 fork 后我想将该 fork 添加为 gitSubmodule 并让它替换我之前安装的当前 Quick 子模块。

更新:我读到以下是最新 git 版本的正确方法,请确认?

To remove a submodule added using:

git submodule add blah@blah.com:repos/blah.git lib/blah
Run:

git rm lib/blah
That's it.

For old versions of git (circa ~1.8.5) use:

git submodule deinit lib/blah
git rm lib/blah
git config -f .gitmodules --remove-section submodule.lib/blah

最佳答案

你有 git submodule deinit

git submodule deinit <asubmodule>    
git rm <asubmodule>
# Note: asubmodule (no trailing slash)
# or, if you want to leave it in your working tree
git rm --cached <asubmodule>
rm -rf .git/modules/<asubmodule>

初始化

Un-register the given submodules, i.e. remove the whole submodule.$name
section from .git/config together with their work tree.

Further calls to git submodule update, git submodule foreach and git submodule sync will skip any unregistered submodules until they are initialized again, so use this command if you don’t want to have a local checkout of the submodule in your work tree anymore.

If you really want to remove a submodule from the repository and commit that use git rm instead.

If --force is specified, the submodule’s work tree will be removed even if it contains local modifications.

关于git - 从 git 版本 1.9.3 开始,删除 git 子模块的方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29850029/

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