Reset local branch to remote branch HEAD
First, reset to the previously fetched HEAD
of the corresponding upstream branch:
git reset --hard @{u}
The advantage of specifying @{u}
or its verbose form @{upstream}
is that the name of the remote repo and branch don’t have to be explicitly specified.
Next, as needed, remove untracked files, optionally also with -x
:
git clean -df
Finally, as needed, get the latest changes:
git pull
Source: StackOverflow