如何在 Visual Studio 2015 中从 Git 获取特定版本? [英] How do you get a specific version from Git in Visual Studio 2015?
问题描述
有没有办法在 Visual Studio 2015 - Team Explorer/Team Services Git 中获取文件的特定版本(来自特定提交)?
Is there a way to get a specific version (from a specific commit) of a file in Visual Studio 2015 - Team Explorer/Team Services Git?
我只是希望使用以前版本的文件运行解决方案,只是为了查看过去运行情况如何,然后返回到最新版本以继续开发.
I simply wish to run the solution with a previous version of a file just to see how things used to run and then come back to the latest version to continue development.
我没有创建任何分支.我一直在master"分支上提交.
I did not create any branches. I kept on committing in the "master" branch.
推荐答案
在 Visual Studio 2015 中,如果您执行 View History(从 Actions团队资源管理器中的 >Changes 面板):
In Visual Studio 2015, if you do View History (from the Actions menu on the Changes panel in Team Explorer):
然后右键单击您感兴趣的提交:
Then right click on the commit you're interested in:
您可以从那里创建一个分支:
You can create a branch from there:
我看不到在 Visual Studio 中只检出提交的方法.
I cannot see a way to just checkout to the commit in Visual Studio.
使用命令行,您可以检查要使用的提交 SHA:
Working with the command line you can do a checkout of the commit SHA you want to use:
git checkout 9eab01d9
完成后,只需再次检查 master:
When you are done, just check out master again:
git checkout master
您可能会收到有关处理分离头的警告,在这种情况下,您可以临时创建一个分支::>
You might get warnings about working on a detached head, in that case you could create a branch temporarily:
git checkout -b temp-branch-name 9eab01d9
熟悉 Git 命令行是个好主意,Visual Studio 工具正在出现,但它缺少很多功能.
It is a good idea to get comfortable with the Git command line, the Visual Studio tooling is coming along, but it misses a lot of features.
这篇关于如何在 Visual Studio 2015 中从 Git 获取特定版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!