Differences between git revert and git Reset

Source: Internet
Author: User
Http://blog.csdn.net/koffuxu/article/details/6731876git revert is to cancel an operation, the operation before the commit will be retained git reset is to cancel a commit, however, all subsequent modifications will be returned to the temporary storage area. For example, there are three commit, git ST: commit3: Add test3.ccommit2: Add test2.ccommit1: Add test1.c. Execute git revert head ~ 1. commit2 is removed from the GIT log. We can see that: commit1: Add test1.ccommit3: Add test3.cgit status has not changed. If you change to execute git reset -- soft (default) Head ~ 1. Run git logcommit2: Add test2.ccommit1: Add test1.c and run git status. Then test3.c is in the temporary storage zone and is ready to be submitted. Execute git reset -- hard head ~ After 1, it will show: head is now at commit2, run git logcommit2: Add test2.ccommit1: Add test1.c to run git St, no changes. In addition: git revert <commit log string> is used to undo the commit and use it as a new commit.

Differences between git revert and git Reset

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.