Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

13
  • 5
    If after git reset your files still differ from the remote, read stackoverflow.com/questions/1257592/… Commented Aug 30, 2012 at 22:31
  • 4
    Git is the strangest thing ever. Git reset --hard done. Then git status: Your branch is ahead by 2 commits. Commented Mar 8, 2013 at 15:19
  • 53
    @shailenTJ "Local changes" here means uncommitted changes, not local commits. git reset --hard affects the former, not the latter. If you want to fully reset to the remote's state, git reset --hard origin/<branch> - but often and in this case, those two commits you're ahead of origin by are work you did, not something you want to throw away. Commented Mar 8, 2013 at 15:23
  • 3
    So this is the same thing as destroying the local repository and re-downloading, right? I just want to be able to force the pull and overwrite changes for convenience. 99% of the time I get this error message when I've accidentally messed something up locally and just want to start over from the repo. Commented Dec 15, 2013 at 19:26
  • 2
    @adelriosantiago Artur's answer also has a reset --hard. It throws away exactly the same as the part of this answer. And yes, throwing things away is potentially dangerous, but it's what the OP asked to do. Their alternative was deleting the directory and re-cloning. They wanted to throw things away. If you want to, say, commit to a local branch and also separately fetch origin's master, great, that's a more common thing to want to do - it's just not what this question was about. Commented Oct 3, 2017 at 18:41