5

I'm a git newbie and am having an annoying error. I've spent a few hours going through different posts on StackOverflow to see how other users solved this, but nothing is working for me.

When pulling from the repo, I get the following error:

error: The following untracked working tree files would be overwritten by merge: upload/.DS_Store

  • I deleted .DS_Store from my Mac, but it just recreated the file.
  • I tried git add ., git stash, git pull and still got the error.
  • I added .DS_Store to .gitignore, but I still get the error.

I have no idea what to do.

Lauren Rutledge
  • 1,195
  • 5
  • 18
  • 27
steeped
  • 2,613
  • 5
  • 27
  • 43

2 Answers2

8

Somebody has added the file already and pushed in the changes you are trying to merge during pull. In most cases it is a mistake.

If you have write access to the repository, remove the file as soon as possible from there. Then merging should succeed.

How to remove them: Github allows to remove files this from web interface, for example. If you cannot do it from web, clone the master branch, call git rm on the file, commit and push. Even if they are auto created, repository will remember them as removed.

Make sure you do no add them again (add the filename to .gitignore)

max630
  • 8,762
  • 3
  • 30
  • 55
  • I need to remove an entire folder but i just see the ability to remove files (not folder) from web interface – Adil Nov 27 '20 at 10:14
1

First untrack that file like described here Ignore files that have already been committed to a Git repository, then add it to gitignore and commit it, and then pull changes. Did it help you?

Community
  • 1
  • 1
grimsock
  • 774
  • 5
  • 18