Version fallback in Git

Source: Internet
Author: User

Git version fallback there are two cases, one is from the local repository (head area) fallback to a version, you can use the command git reset--hard head^ or git reset--hard head~x, head refers to the current version, head^ Refers to a fallback to the previous version, Head~x,x is any number greater than 0, indicating fallback to the previous X versions of the current version. (If you go back to a version from the latest repository and back to the latest repository, you can use the git reflog command to find the ID of each operation, and then use the command git reset--hard ID can go back to the corresponding version)

The second case is to fall back from staging area to the workspace, such as I added filename.txt this file to staging area git add filename.txt, and then I don't want to save it to staging area, you can use the command git reset head Filename.txt, so that when we execute the commit command, the Filename.txt file is not committed to the local repository.

Version fallback in Git

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.