如何在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中,如果您执行查看历史记录(从上的 Actions 菜单中团队资源管理器中的>更改" 面板):
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屋!