Removing .DS_Store Files from Git Repositories

March 27, 2020

If you are a Mac user who also uses Git, you might accidentally commit a .DS_Store file. This could confuse your Windows colleagues, who may wonder what these files do and why you've committed them.

First, what is a .DS_Store file? DS stands for Desktop Services, and these files are used by Macs to determine how to display folders when you open them. For example, they store custom attributes like the positions of icons. These files are created and maintained by the Finder application on a Mac, and are normally hidden.

These .DS_Store files are not useful to Windows users and do not need to be committed to your GitHub repository. To remove existing .DS_Store files from your repository, run the following command:

    find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch

Afterwards, commit the changes to remove those files and push to the remote repository. To prevent these files from being added again, edit your .gitignore file and add the following line:


Doing so will address any concerns your colleagues may have.

Profile picture

Software development professional with expertise in application architecture, cloud solutions deployment, and financial products development. Possess a Master's degree in Computer Science and an MBA in Finance. Highly skilled in AWS (Certified Solutions Architect, Developer and SysOps Administrator), GCP (Professional Cloud Architect), Microsoft Azure, Kubernetes(CKA, CKAD, CKS, KCNA), and Scrum(PSM, PSPO) methodologies. Happy to connect