What is the similar command in git to Intellij’s "git revert"?

Asked

Viewed 214 times

3

How to reverse the state of a specific file via git commands? Similar to option git revert of Intellij where I select the files I want to revert. When I select all options in the git revert, lists me all branches.

daniela.morais@tusk:~/Development/git/oknok-clicktag$ git revert 
Display all 217 possibilities? (y or n)
  • So' to clarify, do you want to revert the status of a file to a specific previous commit? Or simply undo the changes made since the last commit?

  • Undo changes made to a specific file compared to the last commit. (These changes were not "commited")

1 answer

3


To undo changes to a specific file from the last commit (aka discard changes), just do

git checkout -- path/to/file

To revert all files

git checkout -- .

See section "Examples" of Git checkout

  • Man, as someone who started at the Mercurial, every time I have to use checkout to undo changes remember the Steve Losh.

  • @Anthonyaccioly Lol liked the link ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.