Code review at scale is broken. Here’s how Augment Code is fixing it.

Debugging Git Ignore

Last updated on by

Debugging Git Ignore image

Sometimes you might create a file that is unexpectedly ignored by git. Although it doesn’t happen often, it can be tricky to figure out which .gitignore file is responsible for ignoring a file in your project. It is super easy once you know about a handy git command!

For the impatient, the TLDR of figuring out why git ignores a file:

git check-ignore -v path/to/ignored/file

The key is the -v flag to be able to see the path and line number of the ignore file causing your file to be ignored by git.

Example Git Ignore

Let’s go over a quick scenario and then a handy git command you can use to debug which .gitignore file is ignoring a folder/file/etc.

When the culprit is a .gitignore file in a project, it’s more straightforward to figure out why a file is being ignored, however, if you configure a global excludes file in ~/.gitconfig it can be a little trickier to debug and might leave you scratching your head for a minute as to why you don’t see a new untracked file.

Here’s an example of configuring a global ignore file in your ~/.gitconfig. I like to manage this for files I want to be ignored across all my projects, but they aren’t necessarily useful for the project’s .gitignore file:

[core]
excludesfile = ~/.gitignore
# ...

I ran into this recently when trying to create a bunch of Sublime text snippets in a dedicated snippet repo. My global ignore file had this line:

*.sublime-*

I use this ignore rule to ignore *.sublime-project files across all my repositories and inadvertently that includes files that end in *.sublime-snippet.

If you want to try it out, add the above rule to your global .gitignore file and then try to create a .sublime-snippet file in a git project. You should see that creating a file doesn’t look like an untracked file:

touch test.sublime-snippet
git status
# On branch master
# nothing to commit, working tree clean

Next, run the following command to determine why the file is being ignored by using the -v flag:

git check-ignore -v test.sublime-snippet
/Users/paul/.gitignore:5:*.sublime-* test.sublime-snippet

As you can see, the check-ignore command outputs my global ignore file and the line number.

Although the check-ignore command is straightforward once you know about it, it’s a useful thing to learn to troubleshoot ignored files that shouldn’t be ignored quickly.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Filed in:
Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Curotec

Curotec helps software teams hire the best Laravel developers in Latin America. Click for rates and to learn more about how it works.

Visit Curotec
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $3200/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Cut PHP Code Review Time & Bugs into Half with CodeRabbit logo

Cut PHP Code Review Time & Bugs into Half with CodeRabbit

CodeRabbit is an AI-powered code review tool that specializes in PHP and Laravel, running PHPStan and offering automated PR analysis, security checks, and custom review features while remaining free for open-source projects.

Cut PHP Code Review Time & Bugs into Half with CodeRabbit
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit

The latest

View all →
A new beta of Laravel Wayfinder just dropped image

A new beta of Laravel Wayfinder just dropped

Read article
Ben Bjurstrom: Laravel is the best Vibecoding stack for 2026 image

Ben Bjurstrom: Laravel is the best Vibecoding stack for 2026

Read article
Laravel Altitude - Opinionated Claude Code agents and commands for TALL stack development image

Laravel Altitude - Opinionated Claude Code agents and commands for TALL stack development

Read article
JSON:API Resource in Laravel 12.45 image

JSON:API Resource in Laravel 12.45

Read article
Caching With MongoDB for Faster Laravel Apps image

Caching With MongoDB for Faster Laravel Apps

Read article
Laravel 12.44 Adds HTTP Client afterResponse() Callbacks image

Laravel 12.44 Adds HTTP Client afterResponse() Callbacks

Read article