Git - Pull and overwrite local files without touching new files

By xngo on September 17, 2019

If you need to discard all your local changes and get a copy from the remote master branch, then do the followings:

git fetch --all
git reset --hard <remote>/<branch_name>

Note: All your local changes will be lost. However, any files that are not tracked by git(e.g. new files) are not affected.

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.