0

I have create a.gitignore file at my ~ path by this code in my terminal:

touch ~/.gitignore

and also add this file and git defining excludes file by below code:

git config --global core.excludesfile ~/.gitignore

and then remove all of my .DS_Store file using below command

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

(every file has been removed successfully and if I open xCode and press commit the D label appears near this files)

Before I commit I add the .DS_Store to the .gitignore file by this command:

echo .DS_Store >> ~/.gitignore

it also works and write the value in the file but it is not working. Because when I back to xcode and commit the files and then back to finder and navigate to folders and back to xcode, I can see the .DS_Store files in commit dialog too.

Does someone have any idea about what is the problem?

Husein Behboudi Rad
  • 5,434
  • 11
  • 57
  • 115
  • What exactly do you want? A: remove .DS_Store from git repo and never commit these files again or B: ignore the fact that you executed git rm? – BartBog Oct 03 '15 at 13:53
  • 1
    related: http://stackoverflow.com/questions/25700186/ds-store-still-appears-in-git-status-despite-being-in-gitignore – jub0bs Oct 03 '15 at 14:10

1 Answers1

0

After performing the

git rm

you still need to commit those changes

git commit -m "deleted all .DS files"

The next time you will ask git for a diff, these files will no longer show up as modified or "new" because they are in your global gitignore file

BartBog
  • 1,889
  • 14
  • 28
  • *[...] you still need to commit those changes [...]* No; git rm `DS_Store` should be enough. No need to create a commit. – jub0bs Oct 03 '15 at 14:11
  • Nope. After you execute git rm DS_Store, the removal of this file will be staged, but not commited yet. You have to do a git commit before the file is actually removed. As long as you do not commit it, it will still show up as "deleted" in git status (even though it is now in the gitignore) – BartBog Oct 03 '15 at 14:38
  • I think we're referring to two different things. `git rm DS_Store` does delete the file from the working tree, but you're correct, you need to create a commit for the file not to show up in the output of `git status`. – jub0bs Oct 03 '15 at 14:50
  • Indeed, and given the following sentence in the question *"I can see the .DS_Store files in commit dialog too."*, I was guessing that the problem of the author was the fact that these files still show up... – BartBog Oct 03 '15 at 14:51