简体   繁体   English

如何忽略父目录(和git root)中的文件?

[英]How to ignore a file in the parent directory (and git root)?

Given git root with: 给定git root与:

/Guardfile
/local (dir)
/.gitignore

And a .gitignore in local, how to ignore the Guardfile from the .gitignore within local? 而本地的.gitignore ,如何从本地的.gitignore忽略Guardfile

Don't want to change the .gitignore at the root because that is checked into git. 不想更改根目录下的.gitignore ,因为它已签入git。

I tried: 我试过了:

../Guardfile

and

/Guardfile

and

./../Guarfile

git version 2.17.2 git版本2.17.2

Use case (because someone will probably say "Don't do that".). 用例(因为有人可能会说“不要那样做”。)。 It's pretty obvious but I don't want to change the project .gitignore . 这很明显,但是我不想更改项目.gitignore I keep all the files that don't belong in git in the local dir. 我将所有不属于git的文件保留在本地目录中。 But Guardfile needs to be in root dir. 但是Guardfile必须位于根目录中。

someone will probably say "Don't do that" 有人可能会说“不要那样做”

Don't do that. 不要那样做

If you want to ignore a file but not modify an existing .gitignore that's part of the repository, put that in: 如果要忽略文件但修改存储库中现有的.gitignore ,请将其放入:

.git/info/exclude

This files contents are additive with the .gitignore at the base of the repository, and since its in your .git directory, it cannot be checked in. Thus, it will be for your privately ignored files. 该文件的内容是附加的,在存储库的基础上带有.gitignore ,并且由于它位于您的.git目录中,因此无法检入。因此,它将用于您的私人忽略文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM