- On the main menu, choose Reset Head dialog box opens. . The
- From the Git Root drop-down list, choose the required local repository.
- Make sure the Current Branch read-only field shows the branch in which you actually want to reset the HEAD. If necessary, switch to the correct branch.
- From the Reset Type drop-down list, select the desired reset strategy to apply:
- To have the changed files preserved but not marked for commit, select the Mixed option.
The index will be reset while the working tree will not and you will get a report of what has not been updated.
This is the default strategy.
- To have only the HEAD pointer moved without updating the index and the working tree, select the Soft option. Your current state with any changes will remain different from the commit you are switching to.
- To have both the working directory and the index changed to the specified commit, select the Hard option.
- To have the changed files preserved but not marked for commit, select the Mixed option. The index will be reset while the working tree will not and you will get a report of what has not been updated.
- In the To Commit text box, specify the commit you want to reset the current HEAD to.
Type its commit hash or use an expression, for example, of the following structure:
<branch>~<number of commits backwards between the latest commit (HEAD) and the required commit>.
Refer to the Git commit naming conventions for details.
- To check that the specified commit exists and is the one you actually need, click the Validate button.
The Paths affected in commit dialog box shows the files that were affected in the specified commit.
View the information and click OK.
If you specify a commit that does not exist, PyCharm displays an error message.