How Android Studio rolls back code that has been commit

Source: Internet
Author: User

For a commit (not push) code to roll back, this block is a bit unfamiliar to developers who have just turned to git. Today I'm going to say something about this piece:

By convention, first, there is no commit of any code to the push interface, this time there is no commit any content:


I then modified the contents of the String.xml and executed a commit:


The next step is to say how to do revert commit, by selecting the project, right-click, select Git-->repository-->reset HEAD in the popup list ..., Some people might say that my right-click Pop-up list does not find Git options, which can be configured, please poke this:

 is there git in the right-click option for Android Studio?


Here's the analysis:

Git root: Select the directory you want to revert

Current Branch: Which Branch are you in?

Reset Type:

Soft: Choosing this mode means simply revoking a commit, without affecting any of your local files, or any text in the (index) buffer.

Hard: Not only the content of the commit, but also the local file to your commit version, and index will also point to the version before the commit.

Mixed: This pattern is still a little blurry from my point of view. From my point of view is just roll back index, the rest is unchanged.

But here with everyone said, if you put the head behind a "to", here the number represents the number of times, such as you commit three times , you write 1, is to roll back the last commit, if it is 2, is the next two commits are rolled back. At this point you will find that its function is the same as the soft model.

I'll stick to the official statement:resets the index but not the working tree (i.e., the changed files is Preserve D but isn't marked for commit) and reports what have not been updated. This is the default action.

Validate: This option is to see which files are currently affected and what the specific impact is.

My side executes the next soft mode, after the execution completes, looks, the just commit record has gone:



Of course, you want to use the same command line,

git reset [--soft |--mixed [-n] |--hard] head~x   X: Number of Delegates

How Android Studio rolls back code that has been commit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.