Learn how to globally gitignore the .DS_Store file to prevent it from being tracked in Git repositories. This simple configuration ensures that the macOS system file is ignored across all your Git projects.
To globally ignore the
.DS_Store file in Git, you can use the following steps. The key is to add an entry in the global gitignore file. Here's a snippet to help you achieve this:
Open a terminal.
Run the following command to open the global gitignore file in your default text editor. If the file doesn't exist, it will create one for you:
git config --global core.excludesfile '~/.gitignore_global'
Now, open the global gitignore file with your text editor. For example, using
Add the following line to the file:
This line tells Git to globally ignore the
Save and close the file. In nano, you can do this by pressing
Ctrl + X, then
Yto confirm, and finally
Now, Git will ignore the
.DS_Store file globally on your system. Any new Git repository you initialize or clone will automatically apply this global gitignore rule.