如何阻止.gitignore出现在未跟踪的文件列表中? [英] How can I stop .gitignore from appearing in the list of untracked files?

查看:60
本文介绍了如何阻止.gitignore出现在未跟踪的文件列表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在新项目的根目录上做了一个git init.

然后我创建了一个.gitignore文件.

现在,当我键入git status时, .gitignore 文件将出现在未跟踪文件的列表中.为什么会这样?

解决方案

.gitignore文件应位于您的存储库中,因此确实应按照git status的建议添加并提交该文件.它必须是存储库树的一部分,以便可以合并对其所做的更改,等等.

因此,将其添加到您的存储库中,不应忽略它.

如果您确实想要的话,可以将.gitignore添加到.gitignore文件中,如果您不想提交它.但是,在这种情况下,最好将忽略项添加到.git/info/exclude,这是一个特殊的checkout-local文件,其作用与.gitignore相似,但由于它位于.git文件夹中,因此不会显示为"git status".

另请参见 https://help.github.com/articles/ignoring-files

I just did a git init on the root of my new project.

Then I created a .gitignore file.

Now, when I type git status, .gitignore file appears in the list of untracked files. Why is that?

解决方案

The .gitignore file should be in your repository, so it should indeed be added and committed in, as git status suggests. It has to be a part of the repository tree, so that changes to it can be merged and so on.

So, add it to your repository, it should not be gitignored.

If you really want you can add .gitignore to the .gitignore file if you don't want it to be committed. However, in that case it's probably better to add the ignores to .git/info/exclude, a special checkout-local file that works just like .gitignore but does not show up in "git status" since it's in the .git folder.

See also https://help.github.com/articles/ignoring-files

这篇关于如何阻止.gitignore出现在未跟踪的文件列表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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