如何还原到原点的master分支的文件版本 [英] How to revert to origin's master branch's version of file
本文介绍了如何还原到原点的master分支的文件版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在本地计算机的主分支中,该分支是从远程服务器克隆的回购主分支.
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.
我该怎么做?
推荐答案
假定您没有提交文件,也没有将其添加到索引中,然后:
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
这篇关于如何还原到原点的master分支的文件版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文