如何让git忽略git子模块? [英] How to tell git to ignore git sub modules?

查看:762
本文介绍了如何让git忽略git子模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的真实 .git 文件夹位于 / var / www 中。我想将整个文件夹推送到github。不幸的是,一些git子模块被排除在外。



例如文件夹 w / extensions / Lingo 被排除在外。但是 w / extensions / Lingo / .git 不是我的git子模块。 Git仅用于下载 w / extensions / Lingo 并将用于更新该文件夹。



如何告诉我的真正的git /var/www/.git 到忽略任何子模块,如 w / extensions / Lingo / .git



换言之,我想要的告诉git是只要将 / var / www / * 中的任何文件视为普通文件即可。

解决方案

如果您坚持包括子仓库的内容,您可以执行以下操作:

  git submodule deinit Lingo 
git rm -r --cached extensions / Lingo
rm -R extensions / Lingo / .git#(如果它仍然存在)
git add extensions / Lingo

(正如我在如何删除Git子模块?



- cached 确保您不会删除工作树中该文件夹的内容。


My "real" .git folder is in /var/www. I want to push the whole folder to github. Unfortunately, a few git sub modules are excluded.

For example the folder w/extensions/Lingo is excluded. But w/extensions/Lingo/.git isn't "my" git sub module. Git was only used to download w/extensions/Lingo and will be used to update that folder. No own development planed.

How can I tell my "real" git /var/www/.git to ignore any sub modules such as w/extensions/Lingo/.git?

In other words, what I want to tell git is "just treat any file in /var/www/* as normal file".

解决方案

If you insist including the content of a submodule in your repo, you can do a:

git submodule deinit Lingo 
git rm -r --cached extensions/Lingo
rm -R extensions/Lingo/.git # (if it is still there)
git add extensions/Lingo

(As I detail in "How do I remove a Git submodule?")

The --cached make sure you don't remove the content of that folder in your working tree.

这篇关于如何让git忽略git子模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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