How to replace local with remote branch entirely in Git?
I have two branches:
local branch (the one which I work with)
remote branch (public, only well-tested commits go there)
Recently I seriously messed up my local branch.
How would I replace the local branch entirely with the remote one, so I can continue my work from where the remote branch is now?
I have already searched and checked out to the remote branch locally does not have any effect. How git replace local with remote?
Steps required to replace local with remote:
Step 1: Delete your local branch
$ git branch -d local_branch
Step 2: Fetch the latest remote branch
$ git fetch origin remote_branch
Step 3: Rebuild the local branch based on the remote one
$ git checkout -b local_branch origin/remote_branch