Git (TortoiseGit) - How to revert a single file to a previous revision and then undo the revert?

后端 未结 5 1649
感动是毒
感动是毒 2020-12-14 15:29

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 con

5条回答
  •  一生所求
    2020-12-14 15:44

    Updated my answer, based on these comments:

    • by Alexander.
    • by mlibby
    • by Chris Moschini

    Suppose the working tree is clean and you want:

    1. Checkout some file(s) of its previous revision
    2. Testing
    3. Revert to current revision

    1. 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.

    2. Testing

    3. 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)

提交回复
热议问题