Sometimes we just need to reset a local file with what is saved in a remote repository. For example, you’re working locally and your files just get into a place where you need to reset, maybe only a file or two. Maybe you’ve merged in another branch and there are numerous conflicts and you just want whatever the remote branch has, whatever the reason, here are a few commands you can use.
Overwriting a single file
Update your local version of the remote repository, i.e. Origin
git fetch
Checkout the file(s) you want to overwrite
git checkout origin/<remote branch name> <filepath>
Example:
git checkout origin/dev server.js
If you want to overwrite ALL changes you can use the reset
command
git fetch
git reset --hard origin/<remote branch name>