-
Notifications
You must be signed in to change notification settings - Fork 4
[Step 6] Undo a commit locally (Reset)
After step 5, let's say the merge commit was a mistake. We want to undo it.
-
Go to
Synchronization
tab, clickActions > View History
-
It brings up a History tab
-
In the checkout branch, right-click on the commit before the merge commit we just did in step 5 to bring up the context menu.
-
Hover over
Reset
and you can either- Keep Changes, which means the commit will be removed but the change is still there in your workplace
- Delete Changes, which means the commit and changes will be removed.
Need more info? ref
Let's try
keep changes
and re-commit and tryDelete changes
. -
Click
Keep Changes
, and clickRefresh
in the history tab. Review the new branch graph -
In
Team Explorer
, go toChanges
tab, there should be changes, which is the merge changes we made before. -
If we commit it again now, it will just be a normal commit instead of merge commit. Enter commit message and click
Commit All
. It will look like this. -
In History tab, right-click on the previous commit, and click
Reset > Delete Changes
. This will undo the last commit and discard the changes in the workplace. It will be like this after refresh.
The whole process
Related Commands:
- git reset --hard "HEAD^"
- git reset --soft "HEAD^"
- git reset --hard ORIG_HEAD
- git commit --amend
Back to HOME
-
General Operations
-
Advance Operations
-
Workflow