git - 如何忽略我没有写入权限的模块中的更改?
问题描述
我们有一个使用几个 git 模块的项目。遇到了一些问题,我对本地副本进行了一些更改。我没有对模块的提交权限,因此更改将一直保留,直到它们(通过其他方式)传播到正式版本,之后一切都会同步。
在那之前,有没有办法git
忽略.gitignore
这些.git/info/exclude
变化的结果?我不知道该怎么称呼它们,但在 GitHub 中它们看起来像这样:
[] packages/local/Foobar -Subproject commit-[lots of digits]
+Subproject commit-[lots of digits]-dirty
如果我有很多更改的文件,很容易忽略这些以取消勾选它们,最终我会收到 git/GitHub 错误。
解决方案
在git status --help
中,有一个命令行标志可以忽略子模块:
--ignore-submodules[=<when>]
Ignore changes to submodules when looking for changes. <when> can be either "untracked",
"dirty" or "all", which is the default. When "untracked" is used submodules are
not considered dirty when they only contain untracked content (but they are still scanned
for modified content). Using "dirty" ignores all changes to the work tree of submodules,
only changes to the commits stored in the superproject are shown (this was the behavior
before 1.7.0). Using "all" hides all changes to submodules (and suppresses the output of
submodule summaries when the config option status.submodulesummary is set).
如果您想永久忽略脏更改,请将忽略字段添加到您的子模块配置中,.gitmodules
如下所示:
[submodule "foo/bar"]
path = foo/bar
url = git://github.com/foo/bar.git
ignore = dirty
如果您想忽略所有更改,请添加all而不是dirty:
[submodule "foo/bar"]
path = foo/bar
url = git://github.com/foo/bar.git
ignore = all
推荐阅读
- swift - 如何用Core Image实现instagram那种图片滤镜效果
- python - 列表到 csv 文件 - AttributeError:“str”对象没有属性“writer”
- python - PyLint 在 Django 项目中显示应用程序模块文件的“无法导入”错误
- c# - C# Windows 窗体显示 PDF 文件使用 Ppdfview4net(仅显示第一页)
- python-3.x - 什么可以用于自动化 web 服务而不是 selenium-wire?
- r - 问题:无法从 Tripadvisor 获取星级
- python - ValueError:使用 pd.read_html() 时未找到匹配模式“.+”的表
- ag-grid - “空”值的列过滤器
- html - JQuery水平可拖动标尺不平滑
- swift - 嵌入导航栏中时,段控制不起作用[带视频]