[英]Is there a way to go back, after I have pulled latest changes on my VS 2017, without making any changes to the branch or git repo?
My mentor and I are both working on a project in Visual Studio 2017 -directly in the master branch. 我和我的导师都在Visual Studio 2017中直接在master分支中从事项目。 (using GitHub for Visual Studio extension). (使用GitHub进行Visual Studio扩展)。
I recently pulled in his changes (3 commits) but now i want to go back to the state I was in, before pulling the changes. 我最近提取了他的更改(3次提交),但现在我想回到我所处的状态,然后再进行更改。
I searched about git revert, git reset etc. but they seem to make changes to the branch in git. 我搜索了有关git revert,git reset等的信息,但是它们似乎对git中的分支进行了更改。
I want to go back to the previous version of my code - only on my local machine, without disturbing the repository on GitHub. 我想回到我的代码的先前版本-仅在我的本地机器上,而不打扰GitHub上的存储库。 Any way to restore the code to a certain point in the tree, locally, without changing the tree itself? 有什么方法可以将代码本地还原到树中的特定点,而无需更改树本身?
I do not hold much experience in this, Thanks. 我对此没有太多经验,谢谢。
Your question does not provide enough information of the purpose of 'restoring the code to a certain point'. 您的问题没有提供足够的信息来说明“将代码还原到特定点”。
git checkout <sha1_of_a_commit>
. 如果这只是测试特定行为的临时功能或查看代码外观,请查看git checkout <sha1_of_a_commit>
。 And when you've finished, don't forget to return to the master branch with git checkout master
完成后,别忘了使用git checkout master
返回主分支。
git reset --hard <sha1_of_a_commit>
after taking care of having stashed all the uncommitted changes. 如果那是因为您意识到不想从远程拉出提交,请在git reset --hard <sha1_of_a_commit>
所有未提交的更改之后执行git reset --hard <sha1_of_a_commit>
。 And don't be afraid, you can't mess the remote commits until you 'force pushed' which is not advised until you understand what you are doing! 并且不要害怕,除非您“强行推动”,否则您不可以弄乱远程提交,除非您了解自己在做什么,否则不建议这样做!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.