Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I ignore .DS_Store in my untracked files? [duplicate]

Tags:

git

gitignore

I am new to Git, and every time I work with it, I always get this annoying .DS_Store in my untracked files. I am assuming that is where my working directory is.

I have tried searching the answer on Stack Overflow, but only found the answer on how to remove it from the repository, not from the list of untracked files.

How can I tell Git to completely ignore .DS_Store files and never list them as untracked files?

like image 319
Eldan Shkolnikov Avatar asked Dec 05 '14 14:12

Eldan Shkolnikov


People also ask

How do I ignore all untracked files?

You can use the git clean command to remove untracked files. The -fd command removes untracked directories and the git clean -fx command removes ignored and non-ignored files. You can remove untracked files using a . gitignore file.

Should you Gitignore DS store?

DS_Store is a Mac-specific hidden file. It's also not something that you generally want to add to source control, as its contents may change without you necessarily interacting with it. It's safest to place it into your . gitignore file and be done with it.

Why is Gitignore showing up in untracked files?

gitignore file is showing up on the status, because it's untracked, and git sees it as a tasty new file to eat! Since . gitignore is an untracked file however, it is a candidate to be ignored by git when you put it in . gitignore!

How to get rid of DS_Store files on Linux?

How To Get Rid Of Ds_store Files On Linux? Irereous Remove. Access the Terminal window. Make sure the directory you wish to visit is specified using the command line, cd to/your/directory. You should also type a command line phrase: find in the last line. -name ‘. Store DS_Store -type f -delete with the following keys. Enter your information.

How to remove DS_Store from a git repository?

You have to manually remove the .DS_Store files that were added to your repository. You can use git rm --cached .DS_Store. Once removed, git should ignore it. You should only need the following line in your root .gitignore file: .DS_Store.

How to remove untracked files in Git?

If you want to keep your repository nice and clean, the better option is to remove the unnecessary files. This article explains how to remove untracked files in Git. The command that allows you to remove untracked files is git clean.

Where will you see DS_Store files?

Where will you see DS_Store files? The file extension (.DS_Store) starts with a period, signaling a hidden file ordinarily invisible to users. However, you will see them suddenly showing up on the desktop or in an open folder when copied to a Windows PC, copied over a network, restored from a backup, or accidentally enabled Show All Files on Mac.


1 Answers

You could create a .gitignore file. This file tells git which file (changes) it should ignore, so they won't appear in git status, git diff etc. call.

.gitignore is a simple text file. Just create it in a text editor (or edit it if you already have one), and add this line:

.DS_Store

Then, you should add it to the repository, so these files are ignored by all collaborators:

git add .gitignore
git commit -m "added .gitignore"
like image 178
Mureinik Avatar answered Nov 03 '22 00:11

Mureinik