I've been working on a repository for over a year with no issues. Someone else committed to it for the first time, and when I tried to pull their changes, I got this message:
error: The following untracked working tree files would be overwritten by merge:
.DS_Store
I can't find a file called .DS_Store
anywhere in my repository. I added .DS_Store
to my .gitignore
and committed those changes, but I'm still getting the error. Then I tried running git stash
before git pull
but that also didn't help. How do I fix it?
Working in RStudio on a Macbook Pro.
CodePudding user response:
.DS_Store
is a hidden file (because the .
) and you can‘t just see it. In the terminal, you can see it with ls -la
.
Then, if you have already once push .DS_Store
to your repo, you must untrack this file, then only untracked files will be ignored with .gitignore
.
To untrack a file, execute git rm --cached .DS_Store
. Then, when .DS_Store
is correct registered in .gitignore
, you will never see this file on your remote repository.
But there is also no problem, to overwritte the .DS_Store
-file with a merge. These file contain information about system configuration. And for every person where someting push to this repository from a Mac OS, will create the own .DS_Store
. But with correct adding to .gitignore
, this file is no longer overwritten every time.
CodePudding user response:
Someone else committed to it for the first time ...