Git – Force Overwrite of Untracked Working Tree Files

Sometimes we got error ” error: Your local changes to the following files would be overwritten by checkout: ” while we run ” git pull ” or ” git checkout branch “. In that case, if we want to overwrite these files. So what do we do? We use the following:

git fetch –all
git reset –hard origin/master

This grabs the latest repository files without merging and resets the master branch and overwrites the modified ones.