Victor Leung
Victor Leung
BlogFlower shop

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:

.DS_Store

This would then resolve the concerns from your colleagues.


About Victor Leung

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 Professional, Developer and SysOps Administrator), GCP (Professional Cloud Architect), Microsoft Azure, Kubernetes(CKA, CKAD, CKS, KCNA), and Scrum(PSM, PSPO) methodologies.

Happy to connect
LinkedIn
Github
Twitter
@victorleungtw

Continuous improvement

Copyright © victorleungtw.com 2023.