本文介绍了如何摆脱Git子模块未跟踪的状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法摆脱Git子模块中未被跟踪的内容。运行 git status 得到:

 
#分支主
#没有为commit提交:
#(使用git add ...更新将提交的内容)
#(使用git checkout - ...放弃工作目录中的更改)
#(在子模块中提交或放弃未跟踪或修改的内容)

#修改:捆绑/ snipmate(未追踪内容)
#修改:捆绑/环绕(未追踪内容)
#modified:bundle / trailing-whitespace(未跟踪内容)
#modified:bundle / zencoding(未跟踪内容)

没有更改添加到提交中(使用git add和/或git commit -a)

添加 - ignore-submodules 参数隐藏这些消息;但我不知道是否有办法以更合适的核心方式摆脱这种污垢。

既然git状态报告未跟踪的内容,具有干净状态的实际方式是进入每个子模块,并且:


  • add并提交未跟踪的内容

  • 或引用特定于每个模块的 .gitignore 中的未跟踪内容。

  • 或者您可以将相同的忽略内容添加到子模块的 .git / info / exclude 中,如报告的(upvoted )。

      git config -f .gitmodules submodule。< path> .ignore untracked 


  • 或添加全局 .gitignore 文件(通常〜/ .gitignore-global )。就像在。请参阅 :




I can't seem to get rid of untracked content in Git's submodules. Running git status yields:

# On branch master
# Changes not staged for commit:
#   (use "git add ..." to update what will be committed)
#   (use "git checkout -- ..." to discard changes in working directory)
#   (commit or discard the untracked or modified content in submodules)
#
#    modified:   bundle/snipmate (untracked content)
#    modified:   bundle/surround (untracked content)
#    modified:   bundle/trailing-whitespace (untracked content)
#    modified:   bundle/zencoding (untracked content)
#
no changes added to commit (use "git add" and/or "git commit -a")

Adding the --ignore-submodules parameter hides these messages; but I wonder if there's a way to get rid of this dirt in a more suitable, core-ish, manner.

解决方案

Since the git status reports untracked content, the actual way to have a clean status would be to go into each one of those submodules and:

  • add and commit the untracked contents,
  • or reference the untracked contents in a .gitignore specific to each module.
  • or you can add the same ignored content to the submodule's .git/info/exclude, as peci1 reports in the comments.
  • or add dirty to the submodule specification, as mentioned in ezraspectre's answer (upvoted).

    git config -f .gitmodules submodule.<path>.ignore untracked
    

  • or add a global .gitignore file (often ~/.gitignore-global). Like for example .DS_Store or in my case Carthage/Build as reported by Marián Černý in the comments. See .gitginore man page:

这篇关于如何摆脱Git子模块未跟踪的状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 23:20
查看更多