tags:

views:

25

answers:

1

On my local computer's master branch (I cloned a repo from a remote server, master branch).

So I updated a file, and I want to revert back to the original version from the remote master branch.

how can I do this?

+5  A: 

Assuming you did not commit the file, or add it to the index, then:

git checkout filename

Assuming you added it to the index, but did not commit it, then:

git reset HEAD filename
git checkout filename

Assuming you did commit it, and you want to blow away the commit:

git reset --hard origin/master
gahooa
Your third option is very different from your first two options in that it touches all files and not just the one file. You may want to point this out more explicitly. Also why not recommend `git checkout HEAD filename` and `git checkout origin/master filename` for options one and two, it would be more consistent?
Charles Bailey