git reset Rewrite commit

Source: Internet
Author: User
Tags commit reset

Tutorial 3 overwrites the submission. 3. Reset

To save time, this tutorial uses the existing history as a local database.

Download from here

We will use reset to remove the first two commits from the Master branch.

First enter the Stepup-tutorial/tutorial3 directory. The status of the local side history is shown in the following figure.

Confirm the history with the log command.

$ git log
commit 0d4a808c26908cd5fe4b6294a00150342d1a58be
author:yourname <yourname@yourmail.com>
Date:   Mon Jul 23:19:26 +0900 Add pull

    instructions

commit 9a54fd4dd22dbe22dd966581bc78e83f16cee1d7
author:yourname <yourname@yourmail.com>
Date:   Mon Jul 23:19:01 +0900

    Add a description of the commit

commit 326fc9f70d022afdd31b0072dbbae003783d77ed
author:yourname <yourname@yourmail.com>
Date:   Mon Jul 23:17:56 +0900

    Add the instructions for adding add

commit 48eec1ddf73a7fb508ef664efd6b3d873631742f
author:yourname <yourname@yourmail.com>
Date:   Mon Jul 23:16:14 +0900 First

    Commit

Open the Sample.txt file to confirm the content.

Even a monkey knows. git command
add changes input to the index status of the
commit record index to
get the contents of the remote database

Delete the submission with reset.

$ git reset--hard head~~
HEAD is now at 326fc9f add description

Open the Sample.txt and see if "Add a Commit" and "add pull" are gone. or use the log command to confirm the history.

$ git log
commit 326fc9f70d022afdd31b0072dbbae003783d77ed
author:yourname <yourname@yourmail.com>
Date:   Mon Jul 23:17:56 +0900

    Add the instructions for adding add

commit 48eec1ddf73a7fb508ef664efd6b3d873631742f
author:yourname <yourname@yourmail.com>
Date:   Mon Jul 23:16:14 +0900 First

    Commit
                        

Submissions prior to reset can be referenced by Orig_head. When reset is wrong, reset on Orig_head can be restored to the state before reset.

$ git reset--hard orig_head
HEAD is now at 0d4a808 Add pull description
From:http://backlogtool.com/git-guide/cn/stepup/stepup7_3.html

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.