.gitignore Syntax and Comments

Background

I haven’t had much of a need, for my personal stuff, for version control like git, but once I started using it, I kept running into issues with .gitignore seemingly being… ignored.

Here’s the quick answer: Inline comments that follow a pattern break the whole line. Keep comments on their own line.

Bad .gitignore syntax

# this comment is just fine
.git
.idea  # this inline comment doesn't make this folder ignored
**/__pycache__  # this inline comment doesn't make this folder ignored

Good .gitignore syntax

# this comment is just fine
.git
# .idea won't get ignored anymore
.idea
# **/__pycache__ won't get ignored anymore
**/__pycache__

References

  • https://www.atlassian.com/git/tutorials/saving-changes/gitignore
  • https://stackoverflow.com/a/8865858

This is a preview of Clap Button, a new feedback and analytics tools for Hydejack, built by yours truly. You can try it out on localhost for free, but it will be removed (together with this message) when building with JEKYLL_ENV=production. To use Clap Button on your site, get a subscription
and set clap_button: true in your config file.


© 2021. All rights reserved.