Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git failing to ignore .DS_Store defined in global ignore

I'm fairly new to git and hope I'm not doing something terribly silly. I've been living without a way of ignoring files in Git and have finally had my fill of accidentally adding OS files to my repositories.

I have a new git repository the git status of which is:

# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   .DS_Store
#   README.markdown
nothing added to commit but untracked files present (use "git add" to track)

Running git add . followed by git status produces:

# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#
#   new file:   .DS_Store
#   new file:   README.markdown
#

Running git config -l shows:

core.excludesfile=/Users/Chris/.gitignore
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true

The contents of /Users/Chris/.gitignore are:

# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Logs and databases #
######################
*.log
*.sql
*.sqlite

# OS generated files #
######################
.DS_Store?
ehthumbs.db
Icon?
Thumbs.db
like image 215
Chris Kempson Avatar asked Apr 07 '11 11:04

Chris Kempson


People also ask

Should .DS_Store be in Gitignore?

DS_Store file in your directories. It's not a big issue, but often you need to exclude these files explicitly in your . gitignore file, to prevent any unnecessary files in your commit. You may want to ignore this file globally, so next time you don't need to add it to your project's ignore list.

Why is Gitignore not ignoring?

gitignore only ignores files that are not part of the repository yet. If you already git add ed some files, their changes will still be tracked. To remove those files from your repository (but not from your file system) use git rm --cached on them.

What is DS_Store file github?

The . DS_Store file is used to store Finder information about that folder, so it's has no use in a git repo. Follow this answer to receive notifications.


1 Answers

Try removing question mark after .DS_Store in your global .gitignore?

like image 142
Michael Krelin - hacker Avatar answered Oct 01 '22 16:10

Michael Krelin - hacker