Git: How do I force "git pull" to overwrite local files?
Asked 07 September, 2021
Viewed 1.2K times
  • 57
Votes

How do I force an overwrite of local files on a git pull?

The scenario is the following:

  • A team member is modifying the templates for a website we are working on
  • They are adding some images to the images directory (but forgets to add them under source control)
  • They are sending the images by mail, later, to me
  • I'm adding the images under the source control and pushing them to GitHub together with other changes
  • They cannot pull updates from GitHub because Git doesn't want to overwrite their files.

This is the error I'm getting:


  

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

How do I force Git to overwrite them? The person is a designer - usually, I resolve all the conflicts by hand, so the server has the most recent version that they just need to update on their computer.

30 Answer