What's a dotfile? It's a file with a 'dot' in front of it!
The dotfile convention was created by developers as a standard way to store and hide configuration files from regular users
You can create a .gitignore dotfile, either in your repo (per project) or globally (for all projects)
Often, for example when you are building a java application, there are many files that are created, that are not relevant to the project itself.
For example .class files, are compiled java bytecode, they have no place being committed to a shared repository! It's not the actual code.
Another common reason (not a particularly smart one however, but works!) is to prevent the sharing of a secret file i.e a API key for your project. For one man teams (is that even a team? 😆) this might be acceptable. But for larger teams, realistically you should be using a secrets management tool such as HashiCorp vault. NOTE: Your DevSecOps guy will get mad at you if you recommend env variables as they can be exposed in transit. Just saying!
1link$# Check that you do not already have a global .gitignore file
2link$git config --get core.excludesfile
3link$# Create a global .gitignore
4link$git config --global core.excludesFile '~/.gitignore'
1link$# Create a per project .gitignore file
2link$cd my-project
3link$touch .gitignore
4link$# Create a file we will ignore. Will NOT be included when running git add. for example
5link$touch ignoreme.please
6link$echo "ignoreme.please" > .gitignore
7link$git add.
8link$git commit -m "adding gitignore"
9link$git push
GitHub - github/gitignore: A collection of useful .gitignore templates
Home Backstory Why Git? Setting Up GitHub GitHub CLI Your GitHub Profile GitHub Pages Creating A New Repo Cloning A Repository Your First Commit Ignoring Files In Git Stashing Your Changes Branching With Git Merging Git Branches Rebasing Vs Merging Git Workflows Fork And Pull Flow Your First Pull Request Automated Security Alerts Seeing The Differences Removing/Deleting Files Reverting Your Commits Configuring your Git Commit Templates Creating Shortcuts Dotfile Management Sponsoring Open Source Handy Commands Thank You