I\'m in my local computer\'s master branch of a cloned master-branch of a repo from a remote server.
I updated a file, and I want to revert back to the original version
I've faced same problem and came across to this thread but my problem was with upstream
. Below git command worked for me.
git checkout {remoteName}/{branch} -- {../path/file.js}
git checkout upstream/develop -- public/js/index.js
If you didn't commit it to the master branch yet, its easy:
git checkout -b oops/fluke/dang
)git add -u; git commit;
)git checkout master
)Your changes will be saved in branch oops/fluke/dang; master will be as it was.
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, then:
git checkout origin/master filename
Assuming you want to blow away all commits from your branch (VERY DESTRUCTIVE):
git reset --hard origin/master