views:

568

answers:

1

Hi,

When using Git with TortoiseGit: Does somebody know how to change the HEAD to a previous revision for a complete repository and/or just a single file?

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 someting, i don't have a clue how to unrevert it an jump back to the newest revision.

+2  A: 

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 branch

From within TortoiseGit (via Windows Explorer) it looks like you can do this with the following steps:

  • Navigate in Explorer to the folder where the file is.
  • Right-click on the file you want to revert, choose Show log from the TortoiseGit context menu
  • In the top section ("graph") select the revision that has the version of the file you want to revert to
  • In the third section (file list) right-click the file and choose Revert to this revision
  • You should get a message like 1 files revert to e19a77
  • mcl
    Yes you are right, this works perfect with git command line tools, but i am searching for the corresponding functionality in TortoiseGit which also uses git command line tools in the background.
    Alexander
    Seems to be not possible with the current version of TortoiseGit.
    Alexander
    I think I figured this out with TortoiseGit, see edited answer.
    mcl