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:

  • Checkout Jenkins Pipeline Git SCM with credentials?
  • bundle install not running from my post-update hook
  • Is git only good for text files/source code?
  • How to reset staged changes on the remote after a push?
  • Git Post-receive hook with part of work tree
  • Use git rev-list to exclude a branch, but keep common ancestors with the included branches
    • 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 - Use port 9418 for remote on github
  • Setting default diff algorithm does not translate to default merge algorithm (patience)
  • How do I force a subtree push to overwrite remote changes?
  • Using knp snappy bundle to generate pdf - symfony2
  • git-stash vs. git-branch
  • DVCS with a Windows central repository
  • 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.