Git reset command

Source: Internet
Author: User

Git reset has two usage methods: one is to include the path in the Command <paths>. This method does not change the reference, nor does it change the workspace, instead, replace the files in the temporary storage area with files in the specified commit state, which is equivalent to canceling the previous git add operation.


Method 2: If path <paths> is not used, the reference is reset.

Command Format: git reset [-- soft | -- mixed | -- hard] [<commit>]


Parameter -- soft only changes the point of reference and does not change the cache and workspace.


Parameter -- mixed or no parameter is used to change the reference and reset the cache area but not the Workspace


Parameter -- hard not only changes the reference, resets the cache, but also changes the workspace.


Git reset head or git reset does not change the reference or workspace, but only updates the content previously updated to the staging area by using the GIT add command to be removed from the staging area


Git reset -- filename only removes the changes to the specified file from the temporary storage zone, and the workspace and Reference remain unchanged.


Git reset head ^ The workspace remains unchanged, and both the staging zone and reference are rolled back once.


Git reset -- hard head ^ unsubmit completely. The workspace, staging area, and reference are all returned to the last commit state.


I personally feel that git reset commands can be mastered only when they are used repeatedly at work.

Git reset command

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.