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
I like this solution a lot. I hope I remember it the next time I initialize a repository.
Yes, I believe this was made for MacOS users. I don’t need to see your
.DS_Storefiles!Yes. If there’s ever a truly epic Mac zero day, I have faith that whoever finds it will use it to add
.DS_Storeto every Mac’s global.gitignore.I seriously doubt the guys who were selling Pegasus don’t have anything for a platform that has so many hardware level expoits like
https://thehackernews.com/2025/01/new-slap-flop-attacks-expose-apple-m.html
https://www.ibm.com/think/news/apple-m-series-chips-hardware-flaw
or that it will be used for anything besides abusing human rights…
Man, what a stupid idea .DS_Store was.
thumbs.dbFTW!
Or for Dolphin users.
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).
Wow that is really blue, checks background color:
--body-background: blue;I’m surprised it wasn’t
reallyblue
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.
I actually like it a lot for stuff that is user specific, not repo specific. I imagine someone could have a “build.log” to view the build output in some specific way that hooks up to a mini taskbar app or some other random shit.
I’ve personally added some files that don’t relate to the project at all and has no reason for being inside a
.gitignoreand I’ve had to add it many times.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
.swpfiles with Vim’s default settings), or you’re on a Mac which writes.DS_Storefiles 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.
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.
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.
+1 for checking in your config when you can mandate everyone uses the same tool chain. My point is more that the existence of global gitignore supports my open-source use case without precluding your corporate use case.
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>
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.
If you’re contributing to a larger project, it might not be trivial to modify the
.gitignorefile, because you might have to go through a review process and so on. It might be easier to just ignore something locally.It’s not set by default i think?
hello day 1 of bluelightmaxxing this is my blog do you like it
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 bashThen apt install git, check those folders, and finally
exitso 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.
Sounds like you haven’t heard of nix.
The solution to the problem is to install git into a clean system so you can observe what changes it makes.
How would you do this with Nix?
nix-shell -p gitOr some even fancier ones:
nix-store -qR $(nix-build '<nixpkgs>' -A git --no-out-link)or this command (which nix people avoid generally because it creates files outside of the store):
nix path-info -rSh $(nix-build '<nixpkgs>' -A git --no-out-link)or
nix-env -p /tmp/clean-profile -iA nixpkgs.git && nix-store -qR /tmp/clean-profile # then rm /tmp/clean-profile* # to get rid of the temp filesand here’s how I personally implemented a global gitignore on my system. This is a redacted version of my git config:
{ lib, pkgs, ... }: { home.packages = with pkgs; [ diff-so-fancy # git diff with colors git-crypt # git files encryption hub # github command-line client tig # diff and commit view ]; programs.git = { enable = true; settings = { alias = { amend = "commit --amend -m"; fixup = "!f(){ git reset --soft HEAD~\${1} && git commit --amend -C HEAD; };f"; loc = "!f(){ git ls-files | ${lib.exe pkgs.ripgrep} \"\\.\${1}\" | xargs wc -l; };f"; # lines of code br = "branch"; co = "checkout"; cob = "checkout -b"; st = "status"; ls = "log --pretty=format:\"%C(yellow)%h%Cred%d\\\\ %Creset%s%Cblue\\\\ [%cn]\" --decorate"; ll = "log --pretty=format:\"%C(yellow)%h%Cred%d\\\\ %Creset%s%Cblue\\\\ [%cn]\" --decorate --numstat"; cm = "commit -m"; ca = "commit -am"; dc = "diff --cached"; rmain = "rebase main"; rc = "rebase --continue"; }; core = { editor = "nvim"; pager = "diff-so-fancy | less --tabs=4 -RFX"; }; init.defaultBranch = "main"; merge = { conflictStyle = "diff3"; tool = "vim_mergetool"; }; mergetool."vim_mergetool" = { #cmd = "nvim -d -c \"wincmd l\" -c \"norm ]c\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\""; # this command requires the vim-mergetool plugin cmd = "nvim -f -c \"MergetoolStart\" \"$MERGED\" \"$BASE\" \"$LOCAL\" \"$REMOTE\""; prompt = false; }; pull.rebase = false; push.autoSetupRemote = true; url = { "https://github.com/".insteadOf = "gh:"; "ssh://[email protected]".pushInsteadOf = "gh:"; "https://gitlab.com/".insteadOf = "gl:"; "ssh://[email protected]".pushInsteadOf = "gl:"; }; user = { email = "redacted"; name = "redacted"; }; }; ignores = [ "*.bloop" "*.bsp" "*.metals" "*.metals.sbt" "*metals.sbt" "*.direnv" "*.envrc" # there is lorri, nix-direnv & simple direnv; let people decide "*hie.yaml" # ghcide files "*.mill-version" # used by metals "*.jvmopts" # should be local to every project "build/" # smithy lsp ]; signing = { key = "redacted"; signByDefault = true; }; } // (pkgs.sxm.git or { }); }I guess you misunderstood my question, because that won’t work.
nix-shell -p gitdoesn’t provide an isolated operating system. They only isolate programs and libraries. If your native git installation modified something in your home folder, those changes will still be visible inside a nix shell.I’m not sure what you’re trying to accomplish in those other commands, as they just seem to print out git’s dependencies?
Also, I see you’re actively editing your comment as I’m typing so sorry if you actually post the answer after I hit Reply.






