How to use Git to roll back a version to a commit point in a branch

Source: Internet
Author: User
Tags how to use git
git reset [commit hash]

However, this only allows the local branch to be rolled back to the commit, and the remote branch is in its original place.

You can do this: create a new branch on the commit you want to roll back, then git checkout [the branch], then delete the original branch, git branch-d [old branch] can delete the local old branch, similarly, the remote branch or old state, you can git push Origin: [Old branch], delete the old branch of the remote, so that the information you need to rollback the commit is completely wiped out both locally and remotely (be careful to make sure you don't really want the information). And you need to roll back the information before the commit is all saved, but the branch name for a change, you can also rename the branch back. At this point the remote new branch does not exist, and after you change the commit and push, the remote is also synchronized with the local.

How to use Git to roll back a version to a commit point in a branch

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.