Saturday, December 27, 2014

.DS_Store

As a result of switching to this Macbook for my programming purposes, I've gotten to know a little bit about a Mac OS X-specific issue in the past day: .DS_Store files.

These are hidden metadata files present in (all?) Mac OS folders and contain data about the positions of your icons, folder background images (didn't know you could do that), etc.

Their filenames begin with a ".", which is how they're hidden -- my understanding is that this is typically how files are hidden from GUIs in UNIX filesystems. You can easily see them, and any other hidden files with the following (very simple) terminal command, though:

ls -a


Given that these .DS_Store files are hidden, you wouldn't normally notice them.

However, they become quite a source of annoyance when sharing code with version control systems like git, which is exactly how I came across the issue myself.

They'll needlessly pollute your repos and potentially others, should your code be merged in, unless you set your local git configuration to explicitly ignore them.

I learned how to do this from the following Stackoverflow page:

User Turadg compiled information from the best responses and listed two terminal commands that can be entered in order to have git ignore your .DS_Store files. They are:

# specify a global exclusion list
git config --global core.excludesfile ~/.gitignore 
# adding .DS_Store to that list 
echo .DS_Store >> ~/.gitignore

Seems to work. I made a dummy repo on github and uploaded a text file -- no signs of any .DS_Store shenanigans. I rather comically named the repo ".ds_store-ignore-test" (note the ill-advised leading period), so when I cloned it to my computer, sure enough, it was hidden from my OS.

No worries; renamed it from the terminal, but I had a brief chuckle about it.

No comments:

Post a Comment