Eclipse git checkout (aka, revert)

前端 未结 9 1254
感动是毒
感动是毒 2020-11-29 18:02

Is it possible to do the equivalent of git checkout from within Eclipse using the EGit plugin?

I have a file that\'s been modified. I want to discards t

相关标签:
9条回答
  • 2020-11-29 18:53

    Another possibility is using the Git Staging view:

    • Open Git Staging view by pressing Ctrl+3 or Command+3 and typing
      staging
    • In case the view does not already show your repository, click on the project or file
    • You should now see the files you modified in the Unstaged Changes section
    • Double-click on the unstaged file
    • You now see a compare view with your version on the left and the version before the changes on the right

    Now, to undo only some of the changes in the file, do the following:

    • In the compare view, select one of your changed lines
    • Select the Copy Current Change From Right to Left toolbar item

    This will make the left side correspond to the right side for this change. Save the file to finish the undo.

    To undo all of your changes:

    • In the staging view, right click on the unstaged file
    • Select Replace With File in Git Index

    You can also select more than one unstaged file and then right click.

    0 讨论(0)
  • 2020-11-29 18:54

    You can achieve this by doing a (hard) reset. On the project's context menu, select Team > Reset to..., choose "HEAD" and "Hard" as reset type.

    Please note that doing this you will lose the changes of ALL files. To revert just a single file see this answer.

    0 讨论(0)
  • 2020-11-29 19:00

    The functionality is actually in there, but it may be non-obvious:

    • Make sure quickdiff is enabled with a git revision and the quickdiff baseline is HEAD (this is the default).
    • Open the file you want to revert.
    • Select everything (Ctrl-A)
    • Right-Click in the quickdiff bar
    • Select "Revert selection"
    • Save

    btw, revert in git lingo means create a new commit to revert an earlier commit.

    0 讨论(0)
提交回复
热议问题