[Git] Move some commits to a separate branch that I have accidentally committed to master

Gosh no, I just added all of these commits to master. They were thought to be peer reviewed first in a dedicated branch! No worries, in this lesson we’re going to see a couple of commands that will help you move your commits into a dedicated feature branch.

Note: This only holds if you did not yet push your changes to the remote repository

For example, latest commits should goes to feature branch not the master branch.

First checkout a new branch. So that we can keep all the changes we made.

Then back to master branch

What should we do is reset the head to '9a7f06b':

git reset --hard 9a7f06b
原文地址:https://www.cnblogs.com/Answer1215/p/10596619.html