B Seven
B Seven

Reputation: 45941

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

Given git root with:

/Guardfile
/local (dir)
/.gitignore

And a .gitignore in local, how to ignore the Guardfile from the .gitignore within local?

Don't want to change the .gitignore at the root because that is checked into git.

I tried:

../Guardfile

and

/Guardfile

and

./../Guarfile

git version 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. I keep all the files that don't belong in git in the local dir. But Guardfile needs to be in root dir.

Upvotes: 3

Views: 993

Answers (1)

Edward Thomson
Edward Thomson

Reputation: 78873

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:

.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.

Upvotes: 6

Related Questions