+2 votes
1 view
in Devops and Agile by (20k points)
edited by

I have two branches:

  1. local branch (the one which I work with)
  2. 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.

1 Answer

+3 votes
by (28.4k points)

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

by (28.1k points)
Awesome! Great answer.
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...