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 from the remote master branch.
How can I do this?
To move HEAD around in your own Git timeline, use the git checkout command. There are two ways to use the git checkout command. A common use is to restore a file from a previous commit, and you can also rewind your entire tape reel and go in an entirely different direction.
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
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
Can also be done using git restore
git restore --source origin/master filename
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With