Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
June 12, 2022 10:40 am GMT

.gitignore all .DS_Store files, even if already committed

Hello everyone, and welcome to #10stips! The column where you learn how to solve coding issues within 10 seconds.

In today's episode I show you how to .gitignore MacOS .DS_Store files in every folder and subfolder of your project.

A little bit of background

I recently jumped onboard onto an existing Rails 4 project.

Yes, Rails 4 is still widely used in production and oftentimes is particularly challenging to upgrade an application with newer Rails versions without creating breaking changes.

As soon as I cloned the repository, and opened up the code with Atom, I noticed all those magical .DS_Store files.

"Fuck! Back up little bastards!"

shooting at the computer

How to .gitignore .DS_Store files

First, unmatch previously committed files:

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

Then, add **/.DS_Store into .gitignore

Finally, commit and push the changes:

git commit -m "Remove .DS_Store from everywhere"git push

You're welcome!

Now, your Mac will still create .DS_Store files in every folder. If you become frustrated, you can turn them off.

(bonus) How to turn off the creation of .DS_Store files

Mac creates the .DS_Store files to retain settings configured for each folder such as the size and orientation of icons, sort settings, and so on.

If you become frustrated, you can turn off the creation of .DS_Store files - just execute the following command in Terminal:

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

Reboot your Mac, and youll be good to go.


Original Link: https://dev.to/mattiadev/gitignore-mac-dsstore-files-even-if-already-committed-14dm

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To