How do I add files to Gitignore?
There's a good chance if you've seen the ".ds_store" file show up in your repository as a git. If you're not familiar with it, ".ds_store" is a file created by the Finder to store custom attributes of a folder, such as the position of icons or the choice of the background image. If you are a developer that uses git, chances are you have run into the issue of having your .ds_store file show up in your repo. This can be frustrating because it is a file that is specific to your machine and should not be pushed to the remote repository.
You might find that your code commits are being cluttered by .ds_store files. These files are generated by the Finder to store various settings and preferences, and they're typically not needed in your code repository. You can add .ds_store to your gitignore file so that these files will be automatically excluded from future commits.
git ignore all ds_store
echo ".DS_Store" >> ~/.gitignore_global
echo "._.DS_Store" >> ~/.gitignore_global
echo "**/.DS_Store" >> ~/.gitignore_global
echo "**/._.DS_Store" >> ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global
ds_store gitignore
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
git add .gitignore
git commit -m '.DS_Store banished!'
Now we know how you can add .ds_store to your git ignore so that you don't have to deal with this issue anymore.