How to reset to my last commit in Android Studio

后端 未结 5 1932
北海茫月
北海茫月 2020-12-24 01:45

I commit changes to git from Android Studio, after that I have made some changes in my project that gives me errors, and now I want to get back that commited version that ha

5条回答
  •  清歌不尽
    2020-12-24 02:04

    According to this great article on jetbrains webiste here:

    Reset a branch to a specific commit If you notice an error in a set of recent commits and want to redo that part, you can roll back your repository to a specific state. This is done by resetting the current branch HEAD to a specified commit (and optionally resetting the index and working tree if you prefer not to reflect the undo in the history).

    • Open the Version Control tool window Alt+9 and switch to the Log tab.
    • Select the commit that you want to move HEAD onto and select Reset Current Branch to Here from the context menu.
    • In the Git Reset dialog that opens, select how you want your working tree and the index to be updated and click Reset:

    Soft: all changes from commits that were made after the selected commit will be staged (that means they will be moved to the Local Changes view so that you can review them and commit later if necessary).

    Mixed: changes made after the selected commit will be preserved but will not be staged for commit.

    Hard: all changes made after the selected commit will be discarded (both staged and committed).

    Keep: committed changes made after the selected commit will be discarded, but local changes will be kept intact.

提交回复
热议问题