When using Git with TortoiseGit: Does somebody know how to revert a single file(or a complete repository) to a previous revision?
For example I have a repository containing multiple files. One file exists in three revisions (1 ; 2 ; 3). Now I want to change from revision 3 back to 2.
TortoiseGit offers a "Revert" function in the "Show log" dialog which allows to jump back to a specific revision, but this will revert your whole repository instead of a single file.
Also once I have reverted something, I don't have a clue how to undo the revert and jump back to the newest revision.
Updated my answer, based on these comments:
Suppose the working tree is clean and you want:
Checkout some file(s) of its previous revision
(a) Right click the file you want to revert and Show Log for that file
(b) Right click the file in file list and perform Revert to parent revision
(c) repeat (a), (b) until you get all files you want.
Testing
Revert to current revision
(a) perform Revert... in context menu of explorer
This way, you can choose the file(s) you want to revert.
(b) or this quick way: perform Reset Hard in Log dialog
This way, all changed files revert. (=> Lost all working dir changes)
(Tested on TortoiseGit 1.8.16.1, GfW 2.6.4.windows.1, Win 10 64bit)
It is also possible to get a specific file:
TortoiseGit show a dialog with a list of all revisions
In a list in the bottom of the dialog it shows all the files associated with the commit
For example: - original file is file.txt - revision 2 will save as file-67b51a8.txt
I'm using TortoiseGit v2.2.0.0
In TortoiseGit the answer is to right-click the project folder and click Show Log, then right-click the change you want to roll back to and click Switch/Checkout to this... . It will let you then proceed from that weird place in the commit stack, or branch in case you plan to commit and want things to stay sane.
For Tortoise Version 2.3.0:
You can do it in several ways, but fastest i think is that:
From the command line:
git checkout
is probably what you want.The documentation shows an example of:
$ git checkout master~2 Makefile
to revert
Makefile
to two revisions back in the master branchFrom within TortoiseGit (via Windows Explorer) it looks like you can do this with the following steps:
Show log
from the TortoiseGit context menuRevert to this revision
1 files revert to e19a77