GIT:我可以禁止在状态、差异等中列出“修改后的内容”/脏子模块条目吗?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (61)

当Git(我认为是1.6.x发布版)意识到子模块内部的变化时。这只会让我烦恼:

$ git status vendor | grep modified:
#       modified:   vendor/rails (modified content)
$ git diff vendor/
diff --git a/vendor/rails b/vendor/rails
--- a/vendor/rails
+++ b/vendor/rails
@@ -1 +1 @@
-Subproject commit 046c900df27994d454b7f906caa0e4226bb42b6f
+Subproject commit 046c900df27994d454b7f906caa0e4226bb42b6f-dirty

请让它停下来?

提问于
用户回答回答于

ignore = dirty

因此git 1.7.2已经退出,并包括--ignore-submodules可供选择的status.

git help status:

--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).

我想要的价值是dirty.

git status --ignore-submodules=dirty

我使用化名是因为我懒惰:

alias gst='git status --ignore-submodules=dirty'
用户回答回答于

甚至有可能为.gitModule文件中添加的每个子模块设置忽略模式。

就在今天,我遇到了这个问题,在找到解决方案后,我立即在博客上写了一篇文章:如何忽略git子模块中的更改

它的主旨是:

一旦添加了子模块,就会有一个名为.gitmodules在存储库的根中

只需加一行.gitmodules档案:

[submodule "bundle/fugitive"]
    path = bundle/fugitive
    url = git://github.com/tpope/vim-fugitive.git
    ignore = dirty

扫码关注云+社区