As A Dev, Do You Use .gitignore To Ignore Everything And Purposefully Include? Or Do You Just Exclude With It?


Answer :

The second method is the best practice, when it comes to exlude some folder contents of gitignore rules.

It better reflect the following rule:

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

To exclude files (or all files) from a subfolder of an ignored folder f, you would do:

f/** !f/**/ !f/a/sub/folder/someFile.txt 

Meaning: you need to whitelist folders first, before being able to exclude from gitignore files.

It is clearer, shorter (unless you have a large number of folder to whitelist)

What if it is a Joomla install with a large amount of directories and files?
Or what if a core upgrade adds new files or folders

Don't forget you can have multiple gitignore files, one per folder.
That means you can mix and match both approaches.

And you have:

  • http://gitignore.io/ (which does blacklist when it comes to Joomla application)
  • github/gitignore (same approach for Joomla)

Comments

Popular posts from this blog

Chemistry - Bond Angles In NH3 And NCl3

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Change The Font Size Of Visual Studio Solution Explorer