🧐 TIL: global .gitignore (dandean.com)
from CombatWombatEsq@lemmy.world to programming@programming.dev on 11 Feb 01:38
https://lemmy.world/post/42985618

#programming

threaded - newest

hallettj@leminal.space on 11 Feb 02:09 next collapse

Yes, I believe this was made for MacOS users. I don’t need to see your .DS_Store files!

pinball_wizard@lemmy.zip on 11 Feb 05:01 next collapse

Yes. If there’s ever a truly epic Mac zero day, I have faith that whoever finds it will use it to add .DS_Store to every Mac’s global .gitignore.

bobo@lemmy.ml on 11 Feb 07:05 collapse

I seriously doubt the guys who were selling Pegasus don’t have anything for a platform that has so many hardware level expoits like

thehackernews.com/…/new-slap-flop-attacks-expose-…

www.ibm.com/…/apple-m-series-chips-hardware-flaw

or that it will be used for anything besides abusing human rights…

atzanteol@sh.itjust.works on 11 Feb 05:43 next collapse

Man, what a stupid idea .DS_Store was.

talkingpumpkin@lemmy.world on 11 Feb 10:39 collapse

thumbs.db FTW!

tyler@programming.dev on 11 Feb 21:46 collapse

Or for Dolphin users.

bamboo@lemmy.blahaj.zone on 11 Feb 04:08 next collapse

Wow that is really blue, checks background color:

--body-background: blue;
Kissaki@programming.dev on 11 Feb 21:26 collapse

I’m surprised it wasn’t reallyblue

tastemyglaive@lemmy.ml on 11 Feb 05:45 next collapse

hello day 1 of bluelightmaxxing this is my blog do you like it

JakenVeina@midwest.social on 11 Feb 06:40 next collapse

Anyone else dislike the idea? Like, having ignore patterns be ported automatically to everyone that wants to clone the repo just seems… always better than making people do it themselves. At basically no cost.

CombatWombatEsq@lemmy.world on 11 Feb 06:45 next collapse

I really like the global gitignore. I get annoyed when people check in files that are specific to their particular text editor, so I recommend to new contributors adding anything that is specific to their IDE or text editor to their global gitignore so I don’t have to have a bunch of vim and emacs and vs code and atom and webstorm and who even knows what other stuff in my project gitignore.

JakenVeina@midwest.social on 11 Feb 06:57 next collapse

shrug To each their own, I guess.

I can definitely appreciate that opinion, I just… disagree. I don’t really give 2 shits about a file having some stuff in it that I don’t personally use, so long as it still has a purpose. I.E. I’ll take a little clutter in a file like that, that basically never gets looked at or edited, over the chance of cluttering up the repo itself, or PRs, or history with stuff that has no purpose at all.

Jayjader@jlai.lu on 11 Feb 11:25 collapse

I have the same preference for personal projects, but when I was working on a corporate team it was really useful to have the ā€œrun configsā€ for intellij checked in so that each new team member didn’t need to set them up by themselves. Some of the setup needed to get the python debugger properly connected to the project could get quite gnarly.

hallettj@leminal.space on 11 Feb 19:02 collapse

Gitignore settings don’t prevent checking in run configs if that’s what you want to do. Even if someone has the run configs pattern ignored, they’ll get those files with the repo clone. Gitignore only prevents adding files that aren’t already checked in - it’s a guard rail to prevent accidentally checking in so something you don’t want. You can override ignore settings to check in something new in with git add --force <filename>

MonkderVierte@lemmy.zip on 11 Feb 14:17 next collapse

It’s not set by default i think?

zygo_histo_morpheus@programming.dev on 11 Feb 17:44 next collapse

If you’re contributing to a larger project, it might not be trivial to modify the .gitignore file, because you might have to go through a review process and so on. It might be easier to just ignore something locally.

hallettj@leminal.space on 11 Feb 18:54 collapse

Global gitignore is for idiosyncrasies of your computer, not for repo-specific stuff. For example if you use an editor that writes in-place backup or swap files (like .swp files with Vim’s default settings), or you’re on a Mac which writes .DS_Store files into every directory, you’re going to want those ignored for every repo. That way you can comfortably work with other people’s repos, even if they’re not configured for your particular setup.

The global ignore combines with gitignore files in each repo. So if it’s an ignore pattern that everyone working with that repo should have, put it in the repo.

talkingpumpkin@lemmy.world on 11 Feb 10:44 next collapse

There’s also .git/info/exclude, which is a per-repo local (untracked) .gitignore.

You can even add more ignore files via configuration (I don’t recall how).

entwine@programming.dev on 11 Feb 17:04 next collapse

Completely off topic, but

Unfortunately, I didn’t check that before monkeying with things, so I have no idea if I’ve changed my system accidentally.

Reading this makes me feel so powerful to be as familiar as I am with podman/docker (which to be clear is a modest amount). Just do:

podman run --rm -it debian:latest bash

Then apt install git, check those folders, and finally exit so the entire container gets automatically deleted.

The whole thing is done in a few seconds (or more depending on how long git takes to download and whether the debian image is already cached)

Everyone on Linux should have this in their toolbelt.

NostraDavid@programming.dev on 11 Feb 18:13 collapse

I prefer to flip the logic of the .gitignore.

# ignore root files/folders
/*

# unignore files
!.gitignore
!README.md
!Justfile
!flake.nix
!flake.lock
!pyproject.toml
!.python-version
!uv.lock

# unignore folders
!src/
!docs/

# reignore (recursively)
__pycache__

This includes the files and folders (and their subfiles/folders), while recursively ignoring any pycache bullshit.

  • Small
  • Maintainable
  • Easy to change
  • Readable
CombatWombatEsq@lemmy.world on 11 Feb 18:41 collapse

I like this solution a lot. I hope I remember it the next time I initialize a repository.