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

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
Say Thanks
Respond

1 Response
Add your response

2422
Cd02928b9714479b681d1d24bb6360d7

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 ·
Filed Under