I was recently cleaning up an old Git repo, and noticed that some .pyc files got checked in. This got me thinking, and I started reading through the Git documentation to see if there was a way to evaluate .gitignore rules to make sure they were working as expected. Sure enough, Git has the “check-ignore” command. Given the following .gitignore:
$ cat .gitignore
*.env
cluster*
*.pyc
You can pass a pattern to “check-ignore” to get the list of files in your working directory that match the expression:
$ git check-ignore cluster*
cluster1
cluster1.env
$ git check-ignore *.env
cluster1.env
Super handy! After further review, the issue turned out to be a typo in the .gitignore.