by random567 · 10y ago · 0 comments
git reset --hard origin/master
(assuming that the remote is called "origin") With the example in the text, you have to know the number of commits you've made to master. git branch some-new-branch-name
git reset --hard origin/master
git checkout some-new-branch-name git checkout correct-branch
git cherry-pick wrong-branch
git checkout wrong-branch
git reset --hard HEAD~Also, if you have more than one commit before you noticed you were on the wrong branch, this only grabs the one commit.