TortoiseGit - Revert?
I am using TortoiseGit. I want to revert back to a point earlier before i had deleted a few images.
How do i do this, the methods of reverting that i have seen are incorrect....
Right click your working directory and select Show Log from the TortoiseGit menu.
After that you can right click previous commits and reset the branch to that commit.
If you deleted a few files and you have not made a commit yet, Revert will work just fine. Selecting TortoiseGit -> Revert... will display a window for you to select the files you want restored. Deleted files will show in red.
If you already committed the delete, then you can Reset to a commit before you deleted the files. Be warned that if you use reset, you will no longer see in your log the commit(s) after the commit you reset to.
If you want to preserve in your log the commit that deleted the files, you can Checkout the commit before the delete into a new branch, copy the restored files into a separate folder, switch back to your original branch, then add the files back to your original branch.
- Right mouse on a directory or file you are plan on reverting, then Tortoise Git -> Show log.
- Select at the top of window revision you want to revert to then at the bottom part of the screen Right mouse on any file and choose Revert to this revision.
Hope this saves you some time.
Git turns out a horrible nightmare when a merge commit occur. A merge often destroy some of the recent commits/changes. Here is a way to revert a merge and recover the changes via TortoiseGit.
2) Reflog dialog will appear, showing all the recent commits. Right mouse click the Merge commit (the one that caused the problem) and then select the option "Revert change by this commit" -> Parent 2 as shown in the image.|
This will recover all the missing changes to your local repository, commit and push and you should be good to go.