How can I change which commit master points to in git?

  1. Stash your uncommitted changes: git stash
  2. Create a new branch: git branch new_branch
  3. Reset master to origin/master: git reset --hard origin/master
  4. Check out the new branch again: git checkout new_branch
  5. Unstash your changes: git stash pop

Stash/unstash is not necessary if your working tree is clean. Just make sure there are no changes in your working tree, because those will be removed when you reset –hard


Another possibility (faster, and without the need to stash and reset):

  1. Check out a new branch: git checkout -b new_branch master
  2. Create a ‘new’ master branch and point it to origin/master’s commit: git branch -f master origin/master

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)