_-modq
Last Updated: February 25, 2016
·
8.474K
· hobnob

Completely overwrite local master with remote

git

If you need to completely replace the history of your local master with your remote master (for example, if you've been playing with commits or rebase), you can do so by renaming your local master, and then creating a new master branch.

This is achieved by doing the following:

#Rename your local master branch
git branch -m master _old_master_branch_

#Create a new master branch from a remote source
git checkout -b master remoateSource/master

1 Response
Add your response

2422

If you don't need whatever you did in your local master branch, I think this is simper (you don't need to delete your temporary branch afterwards):

git fetch remoteSource
git reset --hard remoteSource/master
over 1 year ago ·