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:

  • Multiple branches of one project with bower
  • Xcode merge two branch Git
  • removing file from commit (Due to file size on the github)
  • Rename remote git branch without fetch
  • Gerrit: Merged, Outdated
  • How to know what differences that “git push” is going to push?
    • 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.


  • How to create a tag on GitHub when a PR is merged?
  • Advice for using Git to manage website development?
  • Git format-patch/bundle for human-readable sneakernet “pull/push”
  • Jenkins + git: “tell me who you are” error, why does it need to tag?
  • How to turn off fast-forwarding in Git?
  • Pushing a new branch in GIT
  • 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.