How do I force an overwrite of local files on a git pull
?
The scenario is the following:
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.
Just like git push --force allows overwriting remote branches, git fetch --force (or git pull --force ) allows overwriting local branches.
The reason for error messages like these is rather simple: you have local changes that would be overwritten by the incoming new changes that a "git pull" would bring in. For obvious safety reasons, Git will never simply overwrite your changes.
No - it only changes the repository, tags snd remote heads - it never changes the working tree, local branches or the index. git pull can change local branches, the local tree and the index. It won't overwrite charges but may do a merge, a rebase or fail if there are conflicting changes.
git pull --force it feels like it would help to overwrite local changes. instead, it fetches forcefully but does not merge forcefully ( git pull --force = git fetch --force + git merge ). Like git push, git fetch allows us to specify which local and remote branch we want to work on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With