.gitignore isn't the only way to ignore files in Git.
Article:
https://nelson.cloud/.gitignore-isnt-the-only-way-to-ignore-files-in-git/Having more than one way to ignore files in Git would seem like an overkill, at least it did for me until I read the article above. This post is a TL;DR for it and actually, the article is not that long. It's 3 minutes read time and 443 words.
So basically, you have 3 options to ignore files in Git.
1. Project-wise, consequential.
Listing files you don't want to commit in
.gitignore file is the first and the most popular way to achieve it and it will somewhat pollute the repository because you have to commit your changes, and it's an extra content in the diff. However, it still might be necessary depending on the file you are ignoring, the ones other people working on the project should NOT accidentally commit.
2. Project-wise, harmless.
You might have files that are only relevant to you but you wouldn't want to commit, your notes or anything, in this case you can list those inside
.git/info/exclude to ignore them in the file tree. Since
.git folder is not tracked by git, it's considered a harmless operation and will not pollute the repository history.
3. System-wise, harmless.
The last one mentioned in the article is to list the files in
~/.config/git/ignore file. This is like the second way but works for all projects and you will not have to do it for every single project so it depends on you to decide.
I have configured git using home-manager, and it has an option for the 3rd way, I have copied it from somewhere else and have been using it without even knowing about it. These are the lines from my nix config:
programs.git = {
ignores = [
".idea"
"node_modules"
# where did this come from? I don't own Apple Device 🗿
".DS_Store"
"*.swp"
];
};It's an interesting article that I found from
lobste.rs, I highly recommend to check both the article and
lobste.rs, you might find some other things that are interesting to you, maybe.
Lobste.rs deserves another article, where I will try to sell it to everyone who doesn't use it regularly.