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.
git reset --hard origin/branch_to_overwrite
– Andrew Atkinsongit branch <branch> -D
2. Reset to a commit before the conflict:git reset <commit> --hard
3. Re-create the branch:git branch <branch>
4. Set tracking to the server:git --set-upstream-to=origin/<branch> <branch> 5. Pull:
git pull` – Nino Filiugit config core.autocrlf false; git ls-files -z | xargs -0 rm; git checkout .
– Chloe