DEV Community

Oliver Davies
Oliver Davies

Posted on • Originally published at oliverdavies.uk on

gitignore - inclusive or exclusive?

Add everything and ignore what you don't want, or ignore everything and explicitly add what you need.

There are two ways to structure a .gitignore file.

The default approach is that all files can be added, and you specify the files and directories you want to ignore.

For example, if my .gitignore file was this, these two directories would be ignored:

vendor
web

Enter fullscreen mode Exit fullscreen mode

The other approach is to ignore everything and unignore the things to add. For example:

*
!build.yaml
!Dockerfile
!docker-compose.yaml
!web/*/custom

Enter fullscreen mode Exit fullscreen mode

Both approaches work and are regularly used.

Which approach do you prefer and why?

Reply and let me know.

P.S. Are you still using Drupal 7 and don’t know what’s involved to upgrade to Drupal 10? Book a Drupal 7 upgrade consultation call or an upgrade roadmap.

Image of Datadog

Master Mobile Monitoring for iOS Apps

Monitor your app’s health with real-time insights into crash-free rates, start times, and more. Optimize performance and prevent user churn by addressing critical issues like app hangs, and ANRs. Learn how to keep your iOS app running smoothly across all devices by downloading this eBook.

Get The eBook

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay