Tired of committing .DS_Store or mysterious log files that haunt your pull requests like bad code reviews from the past So here is a practical guide to a global gitignore that saves your sanity and keeps your version control history less embarrassing
Git can ignore files per repository with a .gitignore file. That is great when the ignore rules belong to the project. But some files come from your machine and not from your code. Think editor swap files system junk and local env files. A global gitignore makes these rules apply to every repo for your user account so you stop seeing the same noise over and over.
Create a file that will live in your home or in your dotfiles repo so you can track it across machines with a tasteful amount of control freakery
touch ~/.gitignore_global
Throw in things that are tied to your workstation or editor and not the project. Keep secrets out of this file and in a proper vault
.DS_Store
node_modules/
*.log
.env
*.swp
.vscode/
Now tell git which file to use as the global ignore. This is a per user setting and will not affect other users or machines until they do the same.
git config --global core.excludesFile ~/.gitignore_global
Make sure git knows about the file with a quick check and then confirm a pattern is ignored
git config --get core.excludesFile
# create a file that matches a pattern then run
# git status to confirm it is ignored
You can also run git status --ignored to see ignored files when you need to inspect what is being skipped
git rm --cached path/to/file
and commit the removalIf you want reproducible developer environments consider including a small recommended .gitignore in project templates and keep the global file strictly personal Use your dotfiles repo to version the global ignore and deploy it across machines with whatever level of nerd discipline you have
A global gitignore is a tiny configuration that saves time and shame. Create the file add sensible patterns tell git where it lives and remember to untrack anything you already committed. Now go forth and commit only the things that matter
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.