Git undo Modification

Source: Internet
Author: User
Tags using git
Supplemental submission

  Git commit-C head-A -- Amend

  -CIndicates reuse of the submitted message. In this example, it is the head, and other valid submission names can be specified.

If the parameter is in lowercase-CThe pre-configured editor is opened to edit and modify the existing submitted message.

  Addition submission can only be applied to the last submission.If you want to correct an error before several commits, you must useGit revertThis command.

 

Reverse commit

Reverse the submitted changes and useGit revertCommand.Create a reverse commit to offset the original changes..

Git usually submits reverse results immediately, but you can also use parameters-NTell git not to commit, which is useful for reversing multiple commits and running multipleGit revert-nCommand, git will save all the changes, and then commit them once.

The submission name must be provided during the reverse operation,The reverse operation always follows the descending order from the new to the old vertex., That is, the final commit is reversed first, which can avoid unnecessary conflicts.

 

Reset

CommandGit ResetAfter you reset the version library,Differences between the reset and version libraries in the temporary working directory treeFor submission.

This is useful when an error is found in the previous submission and changes are required.

This is through-- SoftOption, which makes git save all the differences caused by reset, but does not submit it. After that, you can modify the content and submit it again, or simply discard the content.

Option-- HardBe careful when using this option. This option will be deleted and submitted from both the version Library and the working directory tree,-- HardIt is like the deletion key in the version library and cannot be recovered.

Git reset uses the commit name as the parameter. The default value is head. You can use^And~Specify a version as the modifier of the submission name.

  Head ^ refers to the node on which the version library is reset to the current head., And threw the changes to the head version into the working directory tree,

540ecb7 ~ 3 means to reset to the three nodes before 540ecb7, that is, to throw the two commits (three commits in total) to the working directory tree.

 

 Git reset -- hard head ^Force reset the previous commit.

  Git reset headIt can be used to clear content that has been added to the cache but does not require further submission.

Another method is to useGit Rm -- cached, Option-- CachedIndicates that the cache is cleared and the working directory tree is not moved.

Note:Git checkout filenameWill delete any temporary and submitted changes in the file. This operation is irreversible.

 

References

The path to Version Control-use git (Pragmatic Version Control Using GIT)

Git branch management policy: http://www.ruanyifeng.com/blog/2012/07/git.html

Git reference: The http://gitref.org/


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.