Genji
Genji

Reputation: 51

Symfony .gitignore ignores too much

I have a Symfony 3 project. In the root dir is the usual vendor dir that composer uses for installation.

In the web dir I also have a vendor dir for bootstrap, fontawesome etc.

In .gitignore I have an entry vendor.

Unfortunately both vendor dirs are ignored. But I want to commit the web/vendor dir.

How is that possible?

May be I have found a solution. I added !web/vendor to the .gitignore. Is this the right way?

Upvotes: 0

Views: 642

Answers (2)

Genji
Genji

Reputation: 51

Yes, that was the right way. Just add !web/vendor.

Upvotes: 0

cptwonton
cptwonton

Reputation: 468

gitignore will recursively ignore everything that matches the "vendor" pattern if that is all you have in your gitnore.

There are some basic rules about gitignore you should familiarize yourself with. The one here is that gitignore will run relative to the directory it's in. So, if you add a /vendor entry to the .gitignore in your root dir, then it will only ignore the vendor directory in your root dir. Leave out the slash, and it will drill down as far as it can go and ignore everything that has a vendor in the name, whether it be a file, directory, whatever.

A tip: try looking up sample .gitignore files on github for a specific project type you're using. These are usually good enough to get going. For symfony, a good one is here: https://github.com/github/gitignore/blob/master/Symfony.gitignore

Upvotes: 2

Related Questions