Reset your local master branch to match remote

If you've ever worked with Git, chances are you've encountered a situation where your local master
branch is out of sync with the remote. This can happen if you've made some local changes to the master
branch and want to reset it to match the one on the remote.
The first step to fix this is to make sure you have the latest updates from the remote. You can do this by using git fetch origin
. After that, you can switch to the master
branch using git checkout master
and reset it to match the one on the remote using git reset --hard origin/master
.
# Syntax
# git fetch origin
# git checkout master
# git reset --hard origin/master
git fetch origin
git checkout master
git reset --hard origin/master
# Local `master` branch is now up to date with remote `master`
You can follow this process for any branch, not just master
. Simply replace master
with the name of the branch you want to reset.