YemSalat YemSalat - 1 year ago 303
Git Question

Replace local branch with remote branch entirely

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 (guess every git-newbie has been on my place at some point of time)

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 already searched SO and checking out to the remote branch locally does not have any effect)

Answer Source


git reset --hard origin/master

Assuming that "origin/master" is your remote branch you want to reset to. This updates your local HEAD branch to be the same revision as origin/master, and --hard will sync this change into the index and workspace as well.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download