DEV Community

Regular 🍟
Regular 🍟

Posted on

11 3

Remove .DS_Store File from Git Repo

Time: 2021-03-31 08:43 UTC+8:00

Author: vonhyou

.DS_Store is a file that stores custom attributes of its folder (like icons). .DS_Store is a abbr. of Desktop Service Store . This file is similar to the desktop.ini in Windows OS. So that, it's not necessay to add this file into a git repo. Let me tell you how to remove it by adding .gitignore rules.

  1. If you had already add .DS_Store files into a git repo, you have to delete it using command below:
$ find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
Enter fullscreen mode Exit fullscreen mode
  1. Append a rule to .gitignore file
$ echo .DS_Store >> .gitignore
Enter fullscreen mode Exit fullscreen mode
  1. Update repo
$ git commit -am "remove .DS_Store files"
Enter fullscreen mode Exit fullscreen mode

If you don't want to repeat it, it's possible to set this rule globally.

  1. Creat a new file called .gitignore_global (or any other you like )
$ touch ~/.gitignore_global
Enter fullscreen mode Exit fullscreen mode
  1. Assign this file as a global rule set
$ git config --global core.excludesfile ~/.gitignore_global
Enter fullscreen mode Exit fullscreen mode
  1. Add the rule to .gitignore_global
$ echo .DS_Store >> ~/.gitignore_global
Enter fullscreen mode Exit fullscreen mode

Done.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (2)

Collapse
 
rudra0x01 profile image
Rudra Sarkar β€’

Thanks for sharing.

Collapse
 
ellesatori profile image
Lei β€’ β€’ Edited

Thank you for this. I've done it but .DS_Store is still in my repo. I wonder if there's anything I'm missing?

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay