But one gitignore can't handle the 30-odd files that everyone wants to ignore... I never understood the "PR rejected, just ignore .swp files locally" tbh.
Yes and no. Git actually has a system wide gitignore you can setup to globally ignore files across your whole system. I personally take notes in a notes.md file, so I have a global ignore for it. I don't have you set it up for each repo, and it doesn't pollute the repo's gitignore. If your editor of choice creates temp files or stores project specific configuration in the project directory (e.g. .vscode, etc), they should also be in your global gitignore.
Everyone hates me for being the repo gestapo but the only issues people have with setting up is when they've skipped steps in the doc. No one can be bothered to address that either though so it'll be me automating that too soon.
This doesn't mean that this is the only gitignore. There's usually a project gitignore in any project I work on, and then I have my own, local, gitignore, for very specific things, like my own notes (like a TODO list) and local demo data
This isn't real, right? Git already supports ignores in the global config in your profile folder. I do this sometimes so I can add *.otr.md files to track detailed personal notes on individual project files and directories.
Some very specific CI pipelines. Or if using a big monorepo with hundreds of coworkers working on it.
You use that feature to ignore the main gitignore file and push the one you want into the pipeline. Because you may want to use a file that is normally being ignored for dev or commit to build your soft.
Like having a .env file for each purpose, but you don't wanna mess up with the way your builder is working for that one exception. And it's allowing everyone to have some flexibility to manage their own ignore rules.
If you have a file DatabaseFactory which you modify to provide a development database, you can add DatabaseFactory to the gitignore to avoid committing this change, but you then have a change to the gitignore so maybe this would work to avoid committing that change as well? I can think of a million ways this could go wrong though so idk.
In my experience Claude and Codex like to create a bunch of scripts or build files that I want to git ignore but they are specific to my context/task so I don't need to commit those changes to the git ignore
IMO the proper solution there is to discuss with the team, agree on a naming convention (copilotTemp or some such), and update the agent instructions so that the folder is utilized for things like that, and then add the folder to the .gitignore
You want to gitignore something just for you. You don't want to add it to gitignore file.
For e.g. you have file context.md but much of it's is claude yap. You don't want everyone to see your claude written to file. But you want your clause to read it. So you exclude it.
Build directories are a great example. Instead of hardcoding the output directory in your toplevel .gitignore, you make so that a .gitignore is generated in that directory, ignoring everything, including itself.
Meson is an example of a build system that does this.
By subtracting what it's ignoring from what it's not ignoring, or what it's not ignoring from what it's ignoring (whichever is greater), it obtains a difference, or deviation.
The missile knows where it is at all times. It knows this because it knows where it isn't. By subtracting where it is from where it isn't, or where it isn't from where it is.
It's also worth noting that an ignored file won't be excluded from the repo - it's just harder to accidentally commit it. I've had repos that gitignore "*" and then explicitly add the small number of files that I actually want to track.
You can put extra .gitignore into directories too for special rules. Otherwise, you should include some form of .gitignore if you have a project that will be accepting contributions.
I suppose that makes sense. I know I just could google it, but it the spirit of vibecoding I am going to refrain from searching it up and just assume this is true on based vibes.
There are better (or at least more idiomatic) ways to have a "local only" ignore file if that's what you want, but I've personally never had that need.
I do not understand how people are so confused by what this would do. It is making me feel like I am the one with a knowledge gap.. but I don't think that's it.
Let me try an oversimplified metaphor: the person who plans a road trip doesn't necessarily have to go on it.
1.2k
u/eanat Oct 10 '26
it's completely legitimate way to use gitignore, but I'd recommend to use .git/info/exclude instead of gitignore for this purpose.
74
u/JPowTheDayTrader Oct 11 '26
When the moon hits your eye like a big pizza pie, that's amore.
When a file you don't need exceeds 50 MB, .gitignore.
400
u/NamelessJu Oct 10 '26
the gitignore paradox
it's being ignored by itself, as such it doesn't know to ignore itself anymore, so it looks inside just to ignore itself again, and so on...
(I know that's not how it actually works pls don't crucify me!)
68
u/Zap_plays09 Oct 10 '26
I unironically do this. The closest you are getting is a .gitignore.example file
47
u/fugogugo Oct 10 '26
what will happen tho??
12
u/DogmaticParadigm87 Oct 11 '26
A gitignore that ignores itself is just a file that finally achieved inner peace.
10
u/Fckitman Oct 10 '26
I used stones to destroy the stones
16
u/_ironhearted_ Oct 10 '26
I do this sometimes because I create a bunch of local files to try some things out and i don't want to clutter the actual one with weird names😂
8
u/Noiapah Oct 10 '26
Wait it works recursively?
5
u/Triton1605 Oct 10 '26
5
u/narasadow Oct 10 '26
2
u/Healthy-Use3926 Oct 10 '26
!.gitignore
2
u/Previous_Tangelo5414 Oct 10 '26
This will create a singularly that will tear a hole in the universe.
2
u/PokeRestock Oct 10 '26
How I felt when I deleted recycle bin on Windows Vista
2
u/Fantastic-Bloop Oct 13 '26
This made me laugh way harder than i should have
3
u/Possible_Row_2976 Oct 10 '26
First time I'm seeing this atrocity and it makes me wonder if this is actually a valid use case, like why would someone do this
1
u/e_asphyx Oct 10 '26
pkunzip.zip
1
u/SnugglyCoderGuy Oct 10 '26
1
u/JackNotOLantern Oct 11 '26
Not the best idea
1
u/rafisics Oct 11 '26
to my Overleaf projects :)
1
u/epsi22 Oct 11 '26
*
!.gitignore
1
u/XtraFlaminHotMachida Oct 11 '26
clone, checkout, then rm -rf .* that mf
1
u/poetic_dwarf Oct 11 '26
I used the Stones to destroy the Stones
1
u/HoneydewEntire5741 Oct 11 '26
LOL!!
1
u/Grandviewsurfer Oct 11 '26
I do not understand how people are so confused by what this would do. It is making me feel like I am the one with a knowledge gap.. but I don't think that's it.
Let me try an oversimplified metaphor: the person who plans a road trip doesn't necessarily have to go on it.
1
u/Mobile-Positive-6742 Oct 12 '26
it works becoz gitignore is for local use. I did this sin before.
1
u/unpaid-philosopher Oct 13 '26
Stack overflow error
1
u/Jemnite Oct 15 '26
Finally, an actual joke on this subreddit. Haven't seen one for a while.
0
u/[deleted] Oct 10 '26
[deleted] — view deleted comment