Remove .DS_Store files in git

March 27, 2020

If you are a mac user and using git, you may accidentally commit a file with .DS_Store. Your windows colleague would be confused what does this files do and why do you commit it.

First of all, what is .DS_Store file? DS stands for Desktop Services, which are used for mac to work out how to display folders when you open them. Example of those custom attributes includes the position of icons. These are created and maintained by the Finder application in mac which you normally won’t notice these hidden files.

These files are not useful for windows users and you don’t need to commit them to Github repository. To remove existing files from the repository, you can run the below command:

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

After that, you may commit deleted those files and push to the remote repository. In order to prevent it from being added again, edit the **.gitignore **file and add this line:


This would then resolve the concerns from your colleagues.

Profile picture

Experience in software development, application architecture, and deploying cloud solutions for enterprise customers. Strong hands-on skills with a Master's degree in Computer Science and business acumen with a master of business administration (MBA) in Finance. Certified in Amazon Web Services (AWS), Google Cloud Platform (GCP), Microsoft Azure, Kubernetes (CKA, CKAD, CKS, KCNA) and Scrum (PSM, PSPO) with experience in building banking products from scratch. Connect on Linkedin

© 2022, @victorleungtw