this post was submitted on 11 Oct 2026
435 points (98.9% liked)
Programmer Humor
33585 readers
2012 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
- If the mod doesn't find it funny, you're banned. Ha-ha!... For real: do not use the community for "statements". There are other places for such content. Keep it chill and funny.
founded 3 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Does it prevent the initial .gitignore from being commited too?
For example, what if a file name had sensitive information. It's bad practice, but someone might want to ignore the file while also hiding the ignore rule itself.
Someone might want to selectively omit the second file while keeping the first, but not show what they are hiding.
.gitignore doesn’t prevent things from being committed. It just tells git to ignore files that aren’t already being tracked. And you can easily override that with
-f. Putting.gitignoreinside of .gitignore will ignore itself (if it’s not already tracked).If you're an end user, not a build tool, you'd rather want to place that in
.git/info/excludeinside the repo. It's effectively another gitignore file, which won't be committed.But if you do need something like this for a build tool, then yeah, you can create a file
/test/.gitignorewith these contents:Then running
git add .just adds/test/fake-person-first-last.json.Both
/test/.gitignoreand/test/real-person-first-last.jsonwould be ignored right away.