views:

9187

answers:

3

The scenario is following:

  • my team member is modifying the templates for a website we are working on
  • he is adding some images to the images directory (but forgets to add them under source control)
  • he is sending later the images by mail to me
  • i'm adding the images under the source control and push them to github together with other changes
  • he cannot pull updates from github because git doesn't want to overwrite his files.

the erros i'm getting are:

error: Untracked working tree file 'public/images/icon.gif' would be overwritten by merge.

How to force git to overwrite them? The guy is designer - usually i resolve all the conflicts by hand so on the server is the most recent version that he just need to update on his computer.

+9  A: 

It looks like the best way is to first do:

git clean

To delete all untracked files and then continue with usual git pull....

j t
I tried using "git clean" to solve the same issue, but it did not resolve it. git status says "Your branch and 'origin/master' have diverged,# and have 2 and 9 different commit(s) each, respectively." and git pull says something similar to what you have above.
slacy
would he not need to change to the master branch and then do git clean for it to work? Then he can flip back to whatever development branch he was working from.
foxed
@slacy: Then you need to merge the two branches.
Xiong Chiamiov
git clean is a rather blunt instrument, and could throw away a lot of things that you may want to keep. Better to remove or rename the files that git is complaining about until the pull succeeds.
Neil Mayhew
+7  A: 

Try this:

git reset --hard HEAD
git pull

Should do what you want.

Travis R
+2  A: 

You might find this command helpful to throw away local changes

git checkout <your-branch> -f

and then do a clean up

git clean -f
Vishal