Search code examples
gitgit-gui

How do I discard changes for a file in Git Gui?


Often when using Git Gui I would like to reset/checkout a single file or just dismiss a hunk.

Is there a way to do this easily in Git Gui? If not, is there any particular reason that this feature is not available in Git Gui?


Solution

  • I know this way:

    1. The changes must be unstaged
    2. Go to Tools -> Add
    3. Choose whatever name you'd like for your command, then in Command write
      git checkout $REVISION -- $FILENAME
    4. Select (left-click) the file you want to checkout, without staging
    5. Choose from Tools the command you just created

    The chosen file will be checked out to HEAD revision