如何摆脱Git子模块未跟踪的状态? [英] How to get rid of Git submodules untracked status?
问题描述
我似乎无法摆脱Git子模块中未被跟踪的内容。运行 git status
得到:
#分支主
#没有为commit提交:
#(使用git add ...更新将提交的内容)
#(使用git checkout - ...放弃工作目录中的更改)
#(在子模块中提交或放弃未跟踪或修改的内容)
#
#修改:捆绑/ snipmate(未追踪内容)
#修改:捆绑/环绕(未追踪内容)
#modified:bundle / trailing-whitespace(未跟踪内容)
#modified:bundle / zencoding(未跟踪内容)
#
没有更改添加到提交中(使用git add和/或git commit -a)
添加 - ignore-submodules
参数隐藏这些消息;但我不知道是否有办法以更合适的核心方式摆脱这种污垢。
既然git状态报告未跟踪的内容,具有干净状态的实际方式是进入每个子模块,并且: https://stackoverflow.com/users/926719/ezraspectre\">ezraspectre 的答案(upvoted )。 或添加全局
.gitignore
中的未跟踪内容。
.git / info / exclude
中,如 speci1 报告中提到的
git config -f .gitmodules submodule。< path> .ignore untracked
.gitignore
文件(通常〜/ .gitignore-global
)。就像 .DS_Store 或者我的情况 Carthage / Build
stackoverflow.com/users/1318739/mari%C3%A1n-%C4%8Cern%C3%BD\">马里安Černý在评论。请参阅 .gitginore
手册页 :
用户希望Git在所有情况下都忽略的模式(例如,备份或由用户选择的编辑器生成的临时文件)通常进入由用户的
中的
。它的默认值是core.excludesFile
〜/的.gitconfig$ XDG_CONFIG_HOME / git / ignore
。如果$ XDG_CONFIG_HOME
未设置或为空,$ HOME / .config / git / ignore
被用来代替。
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 caseCarthage/Build
as reported by Marián Černý in the comments. See.gitginore
man page:
Patterns which a user wants Git to ignore in all situations (e.g., backup or temporary files generated by the user’s editor of choice) generally go into a file specified by
core.excludesFile
in the user’s~/.gitconfig
. Its default value is$XDG_CONFIG_HOME/git/ignore
. If$XDG_CONFIG_HOME
is either not set or empty,$HOME/.config/git/ignore
is used instead.
这篇关于如何摆脱Git子模块未跟踪的状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!