How to update 1 branch local (say A) - to match exactly the remote branch A
- If you have any commits made locally, remove them - match the remote branch A.
- Any untracked files also remove.
develop branch is an example case of A - I always try to keep my local develop branch matching to remote because I never do commits directly to develop branch locally apart from updating local develop to match remote develop.
Useful when develop branch has unwanted changes.
git checkout master
git reset --hard origin/master
That is,
- Switch to that branch A,
- and
reset --hard
origin/A
This SO has good details.