Git ignores .gitignore with .gitignore in .gitignore


I initialised a new Git repository, and added a .gitignore file instructing git to ignore .gitignore:

git init .
echo ".gitignore" > .gitignore
git status

And the result:

On branch trunk
No commits yet
nothing to commit (create/copy files and use "git add" to track)

Therefore, we can see Git ignores .gitignore because its in .gitignore, which means it didn’t ignore .gitignore for instructions.

Is any of this informative, surprising, or useful? … Absolutely.

Update: Some Hacker News and Reddit readers have missed the silly tone or read this literally. This isn’t surprising! But I’ll endeavour to be a bit more overt with my nonsense in the future. Maybe I should have linked to yesterday’s Frog and Peach first.

Author bio and support


Ruben Schade is a technical writer and infrastructure architect in Sydney, Australia who refers to himself in the third person in bios. Hi!

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite bespoke cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or send a comment. Thanks ☺️.