I have a git repository, with ignored paths specified in .git/info/exclude
as they are specific to this clone. I wish to exclude a directory /foo
(and everything below it) which is located at the root of the repository. However, I do not want to ignore /foo-x
or /y/foo
. I have played around with ignore patterns but cannot work out how to do this. Is it possible?
Add a comment
|
2 Answers
Try to add to .gitignore
(for all users that will clone your repo) or .git/info/exclude
(only for your machine) this:
/foo/
Note, that
Files already tracked by Git are not affected;
by gitignore
. So, you should git rm
them from the repo!
-
-
@AndrewHo I believe you're doing something wrong. I've checked it:
$ cat .git/info/exclude:
/data/
$ git status
:# Untracked files: # (use "git add <file>..." to include in what will be committed) # # data-x
Feb 20, 2016 at 16:38 -
-
You were right. I had the solution all along, but was careless when testing it! Feb 20, 2016 at 16:59
-
Can I add, make sure to include that leading /. If you don't then git will ignore all directories named foo even if they are not in the root. I've been learning that the hard way for months now! I just figure out the problem today.– z2kJan 2, 2018 at 20:17
You can add it into .gitignore
(for all) or .git/info/exclude
(for you)
foo/
You can end patterns with a forward slash /
to specify a directory.