HowTo: Revert local changes in Git

Found this answer on Stack Overflow very useful, so thought I’d share it here:

If you want to revert changes made to your working copy, do this:

git checkout .

If you want to revert changes made to the index (i.e., that you have added), do this:

git reset

If you want to revert a change that you have committed, do this:

git revert ...

Source: How to revert all local changes in a GIT managed project to previous state ?

  • http://advomatic.com dalin

    I'm just starting to think about Git.

    By what you've written here there seems to be some unfortunate naming choices:

    git revert == svn merge

    svn revert == git checkout

    :P

  • caphun

    Haha, I'm having to battle with svn, git and mercurial! Can imagine how confused I am now. :P

    Here's a good place to start if you're switching from svn to git:

    http://git.or.cz/course/svn.html

  • Pingback: lastactionseo | lastactionseo - der letzte SEO