0

In my .gitignore I have the line:

/storage/*.key

But I don't want to ignore this specific path and all it's content:

/storage/app/public/*

Now, inside that path there's another .gitinore file and it has:

*
!.gitignore

And in the same path there's another .gitignore with:

*
!public/
!.gitignore

I thought that would be for add the path but is not working.

What is that? How can do what I want (add the path of storage/app/public*)?

pmiranda
  • 7,602
  • 14
  • 72
  • 155

1 Answers1

0

Simply check which exact .gitignore and which exact rule is ignoring public:

cd /path/to/my/repo
# from the root folder of the repo:
git check-ignore -v /storage/app/public/aFileWithinPublic

You need to test a file, since a folder is not tracked by Git.

The rule is simple:

It is not possible to re-include a file if a parent directory of that file is excluded.

So if the folder public is ignored (by a '*' rule in a parent .gitignore) of if any of the parent folder of public is ignored, no amount of exclusion will be able to make public content not-ignored.

So this is good (from the .gitignore in storage/app/, parent of public/ folder):

*
!public/

But if storage/app/ or storage/ are ignored themselves, this exclusion would be ignored as well.

That is why git check-ignore -v /storage/app/public/aFileWithinPublic is important: it will explain what causes the folder content to still be ignored.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250