Is there a git revert similar to svn revert? I need a single command to erase *everything* in my local and set it to remote head

In svn or subclipse, I can simply do a ‘revert’ on the root project and all my local changes are discarded and src is updated to the latest in HEAD. I don’t seem to find an equivalent of this in git though several blogs claim the same.

This is what I did:

  • Git ignore file for VB.NET projects
  • Git Development Strategy for Small Team
  • git error “Please tell me who you are.” and Heroku
  • Make the current git branch a master branch
  • Python subprocess “git gc” stderr is not captured
  • Why says git “both modified” when outputting git status after conflict?
    • committed 10 files from my home mac. did not push.
    • committed the same 10 files and more from work computer and PUSHED.
    • came back home and I want to take the latest from remote origin/master.

    tried git pull, it brought in changes but warned of conflict

    tried git reset --hard HEAD, but nothing happened. I still see the committed conflicted changes

    I must’ve tried few other commands I don’t remember. I just need to get back to remote head and not worry about what state my local repo is.


  • git svn dcommit always fails with “Cannot dcommit with a dirty index.”
  • Jenkins cannot read Github password since upgrading to Git client plugin 2.1.0
  • Why does Heroku think everything is up-to-date when it isn't?
  • Multiple simuntaneous changesets with Git
  • Get latest git tag from the current commit
  • cherry-picking commit - is commit a snapshot or patch?
  • 4 Solutions collect form web for “Is there a git revert similar to svn revert? I need a single command to erase *everything* in my local and set it to remote head”

    You need to reset to origin/master:

    git reset --hard origin/master

    git reset --hard @{u} will throw away all local changes and reset your current branch to its upstream branch. This only works if you’ve set that information (e.g. by cloning with a recent version of git, or by using git push -u). If you don’t have that info but you know the upstream branch, you can use git reset --hard origin/master (assuming origin/master here is the name of the upstream branch).

    You want git reset, but you probably want to go back one commit earlier, since you committed those files to your HEAD on the home mac.

    git reset --hard HEAD^

    If you’re concerned about wrecking something up, you can always do git log, grab the hash for the commit you want to go back to (discarding your home mac changes), and git reset --hard to that hash.

    For simple revert you can use: git checkout

    git checkout <master>
    Git Baby is a git and github fan, let's start git clone.