删除 git 子模块的当前方法是什么? [英] What is the current way to remove a git submodule?

查看:19
本文介绍了删除 git 子模块的当前方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我认为可行的步骤是这里,但评论说他们不会.

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

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

要删除使用以下方法添加的子模块:git 子模块添加 blah@blah.com:repos/blah.git lib/blah跑:git rm lib/等等而已.对于旧版本的 git(大约 1.8.5)使用:git 子模块 deinit lib/blahgit rm lib/等等git config -f .gitmodules --remove-section submodule.lib/blah

解决方案

你有 git submodule deinit

git submodule deinit git rm # 注意:asubmodule(没有尾部斜杠)# 或者,如果你想把它留在你的工作树中git rm --cached rm -rf .git/modules/

<小时>

deinit

<块引用>

取消注册给定的子模块,即删除整个submodule.$name
.git/config 中的部分以及他们的工作树.

进一步调用git submodule updategit submodule foreachgit submodule sync跳过任何未注册的子模块直到它们再次初始化,因此如果您不想再在工作树中对子模块进行本地检出,请使用此命令.

如果您真的想从存储库中删除子模块并提交,请改用 git rm.

如果指定了--force,子模块的工作树会被删除,即使它包含本地修改.

as of git version 1.9.3 (Apple Git-50) on mac how do i remove a git submodule? I am reading alot of outdated information with many developers telling me they wont work. What is the current way ? will git deinit pathToSubModule do the trick ?

The steps i thought would work are here but comments say they wont.

Let me explain my current situation and what i need accomplished. I've installed the Quick repository and added it to as submodule to my project. This code is already checked in and others are using it. What i now need to do is fork the same Quick repository and host it on a more secure github that my company has (so a completely other private github). After forking it i want to add that fork as a gitSubmodule and let it replace the current Quick submodule i had installed previously.

update: i've read that the following is the correct way on latest git version please confirm?

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

解决方案

You have the 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>


deinit

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 子模块的当前方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆