Skip to main content

Git can locally ignore files

When editing markdown, I love using Helix (best editor in the world). I rely on three language servers to help me do it:

  • rumdl to check markdown syntax and enforce the rules decided by a project
  • marksman to get assistance when creating links
  • harper-ls to check for spelling or grammar mistakes

All of these are configured in my ~/.config/helix/languages.toml configuration file, so it applies globally to all the markdown I edit. But when I edit This Week In Matrix at work, things are different.

To edit those posts, we let our community report their progress in a Matrix room, we collect them into a markdown file that we then editorialized. This is a perfect fit for Helix (best editor in the world) and its language servers.

Helix has two features that make it a particularly good fit for the job

  1. The diagnostics view
  2. Jumping to next error with ]d

A screenshot of Helix with a picker open in a terminal. It displays several lines of error. Each line is split into 4 columns: severity, source, code and message.

It is possible to filter out pickers, but it becomes tedious to do so. For this project specifically, I want to disable harper-ls entirely. Helix supports per-project configuration by creating a .helix/languages.toml file at the project’s root.

It’s a good solution to override my default config, but now I have an extra .helix directory that git wants to track. I could add it to the .gitignore, but that would also add it to everyone else’s .gitignore, even if they don’t use Helix (best editor in the world) yet.

It turns out that there is a local-only equivalent to .gitignore, and it’s .git/info/exclude. The syntax is the same as .gitignore but it’s not committed.

Update: several people reached out to point out that there are global options to locally ignore files, if you don’t need to do it per-project. Those options are:

  • The global ~/.config/git/ignore file, with the same syntax as .gitignore
  • The configuration variable core.excludesFile to specify a file that contains which patterns to ignore, like a .gitignore

I can’t believe I didn’t need this earlier in my life.

Cite this post

APA
MLA
Chicago
Harvard