Resetting a local branch to a previous state

Resetting a local branch can be done in two different ways. The first one could be resetting the branch to the last committed state available in the local repository. During this, you can select whether to keep your changes or not, but the most common way is to undo all the uncommitted changes that happened in the local branch.

To reset a branch, open Team Explorer and navigate to the Branches view. As shown in the following screenshot, right click on the branch that you want to reset. From the context menu, select Reset | Delete Changes (--hard) to undo all the uncommitted local changes:

The other option could be resetting the local branch to a specific commit. All the changes available until that selected commit will be undone and will provide you with a fresh working copy of your files.

To reset a branch to a specific commit, open the History page of the branch and right click on the commit that you would like to reset to. From the context menu, select Reset | Delete Changed (--hard), as shown in the following screenshot:

Note that the reset operation affects the entire branch that has been selected, not just those available in your current directory.

Upon doing so, the local branch will have the changes up to the selected commit from the commit history. The History page will add another section that will list the incoming commits, which if needed, can be pulled to the local branch:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.186.6