Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are all these hidden ('._' prefixed) files that are in my git repo?

Tags:

git

When I do a 'git status' on my directory, it shows a bunch of untracked files that seem to be duplicates. The only difference is that all have a prefix of ._. For example: One of my untracked files that needs to be added would be... app/assets/stylesheets/categories.css and another file would display as app/assets/stylesheets/._categories.css.

Does anyone know what this is all about? There seems to be no good documentation on GitHub.

like image 344
Jakcst Avatar asked Apr 25 '12 20:04

Jakcst


3 Answers

As mentioned here:

if for file foo you have another ._foo, and you're on a Mac, the dot-underscore file is where the file resource fork / metadata is kept.

(Described in more details in "DS_Store, dot underscore (._), resource forks and annoyed Windows users")

The .DS_Store is similar to the thumbs.db file Windows XP makes and is used to store “custom attributes of a folder such as the position of icons or the choice of a background image.”

The dot-underscore (._) files are pesky little buggers. It seems that when you use the Finder to transfer files to a non-Mac system–a Windows Server in this case–it splits the file into two parts – the data and the resource forks. When you copy the file back to the Mac, the Finder merges the two bits again. Windows can’t use the resource fork, so it’s not needed and you can delete it, but it’s a lot of hassle having to clean up after others!

See also "Is there any way to prevent a Mac from creating dot underscore files?"

like image 110
VonC Avatar answered Oct 11 '22 19:10

VonC


If you update your global .gitignore (at C:/Users/user/.gitignore or wherever your user home directory is), you can add this line:

._*

It will prevent these from showing up when you do a git status, and they will not be added via git add -A.

This is what I add to mine to prevent various operating systems inserting garbage into our repos.

# OS generated files #
######################
.DS_Store?
ehthumbs.db
._*
# Icon?
Thumbs.db
like image 37
Alan D. Avatar answered Oct 11 '22 19:10

Alan D.


They have nothing to do with git per se; they're metadata files created by OS X.

like image 43
geekosaur Avatar answered Oct 11 '22 19:10

geekosaur