How to revert Git to the previous version in Android Studio (IntelliJ IDEA)

When you coding and found error and hard to solve you may need to go back to the previous version. I just found one simple way to do in Android Studio (IntelliJ IDEA) .

1. StashChange Methods for revert back to lastest local commit.
just Press (Alt+9) to open VCS Control then select local/Default then select every file you want to discard change. Then Right Click Git/Repository/StashChange as shown in the picture below. 
The Android Studio (IntelliJ IDEA) will keep all change to the stash then discard all change from the head commit. This will revert back to last commit.

1. Reset Head commit Methods for revert back to specific local commit.
If you want to revert to specific commit you have to reset Head commit by goes to main menu select VSC/Git/Reset HEAD as shown in the picture below. 
Now, let’s specify the commit to reset the HEAD to. The required format is <branch name>~<number of commits backwards between the current HEAD and the required commit>. 

We want to discard one commit, the last one. So type AndroidStudio~1 (AndroidStudio is the name of current branch) in the To Commit text box. Click Validate to make sure that you select the right specified target commit. After you validated just click reset then do the First Method (StashChange Methods for revert back to lastest local commit.)


Reset Type Use this drop-down list to define the reset method to use. The available options are:
Mixed - the default strategy. When this option is selected, the index is reset while the working tree is not, which means that changed files are preserved but not marked for commit. You are presented with a report of what has not been updated.
Soft - when this option is selected, the index and the working tree are not affected, only the HEAD pointer is moved to the specified commit. Your current state with any changes remains different from the commit you are switching to. All the changes are "staged" for committing.

Hard - when this option is selected, both the working directory and the index are changed to the specified commit.

ref. 
wiki.jetbrains.net/intellij/Using_Git_Locally

www.kernel.org/pub/software/scm/git/

www.jetbrains.com/idea/webhelp/reset-head-dialog

Popular posts from this blog

เทคนิค ชนะ เกมเศรษฐี 14 ตารวด!!! ( Let's get Rich )

Using Google Chrome Inspect Element to Analyze the website

Easy way to download whole youtube play list and convert them to mp3