强制git向库中添加点文件 [英] Force git to add dotfiles to repository

查看:202
本文介绍了强制git向库中添加点文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在git repo中添加以点(隐藏文件)开头的文件? Git似乎总是忽略这些。



当我输入git add。时,GIT_DIR中的点文件将被添加,但不会从子目录中添加。另一方面,git add subdir / .dotfile将不起作用。



我尝试了git add -f并将!。*放入GIT_DIR /.git/info/exclude。

解决方案

git add。 git add dir / .dot 对于我现在使用的Git的1.6.6.1和1.7.0版本的工作很好。

 %git --version 
git版本1.6.6.1
%git ls-files -o
.baz / baz
。 foo
bar / .bar
quuux / quuux
quux
%git add。
%git ls-files -o
%git ls-files
.baz / baz
.foo
bar / .bar
quuux / quuux
quux

您使用的是什么版本的Git?你的subdirs实际上是submodules(它是独立管理的)吗?



点文件在默认情况下不会被排除,但可能在您的系统,存储库或工作树有他们设置的方式。如果它们出现在 git ls-files --exclude-standard -oi 中,那么它们将被忽略,!。*是正确的方式来取消它们。但要有效,这种模式必须在正确的地方。按照以下顺序处理忽略:




  • .gitignore 立即包含的目录,然后
  • $然后
  • $ GIT_DIR / info / b

    <排除
    ,然后

  • git config core.excludesfile 报告的文件(可由
    设置

    • $ GIT_DIR / config

    • $ HOME / .gitconfig ,或

    • 系统配置文件(尝试 GIT_EDITOR = echo git config --system --edit 以获取其路径名))。




当路径名与一个文件中的模式匹配时,不会查询后续文件。每个文件中的最后一场比赛胜出。 $ GIT_DIR / info / exclude 中的模式不能覆盖 .gitignore 文件中的模式。因此,如果文件被忽略(每个 git ls-files --exclude-standard -oi ),并且 $ GIT_DIR / info中的!。* / exclude 不起作用,然后检查所有适用的 .gitignore 文件以找到罪魁祸首。


How can I add files starting with dot (hidden files) in git repo? Git seems to always ignore those.

When I type "git add .", dotfiles in GIT_DIR are added, but not from subdirectories. On the other hand, "git add subdir/.dotfile" won't work.

I tried "git add -f" and putting "!.*" in GIT_DIR/.git/info/exclude. No luck.

解决方案

git add . and git add dir/.dot work fine for me with the unadorned 1.6.6.1 and 1.7.0 versions of Git that I have handy right now.

% git --version
git version 1.6.6.1
% git ls-files -o
.baz/baz
.foo
bar/.bar
quuux/quuux
quux
% git add .
% git ls-files -o
% git ls-files 
.baz/baz
.foo
bar/.bar
quuux/quuux
quux

What version of Git are you using? Are your subdirs actually submodules (which are managed independently)?

"dot files" are not excluded by default, but maybe some bit of configuration on your system, repository, or working tree has them set that way. If they show up in git ls-files --exclude-standard -oi then they are being ignored and "!.*" is the right way to ‘unignore’ them. But to be effective, that pattern has to be in the right place. Ignores are processed in this order:

  • .gitignore of the immediately containing directory, then
  • .gitignore of the parent directory (each parent, up to the repository root), then
  • $GIT_DIR/info/exclude, then
  • the file reported by git config core.excludesfile (which could be set by
    • $GIT_DIR/config,
    • $HOME/.gitconfig, or
    • the system config file (try GIT_EDITOR=echo git config --system --edit to get its pathname)).

When a pathname matches a pattern in one file, subsequent files are not consulted. The last match in each file "wins". A pattern in $GIT_DIR/info/exclude can never override a pattern in a .gitignore file. So, if the files are being ignored (per git ls-files --exclude-standard -oi) and if "!.*" in $GIT_DIR/info/exclude is ineffective, then check all the applicable .gitignore files for the culprit.

这篇关于强制git向库中添加点文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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