Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get a specific version from Git in Visual Studio 2015?

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.

I did not create any branches. I kept on committing in the "master" branch.

like image 780
TchiYuan Avatar asked Jul 26 '16 20:07

TchiYuan


People also ask

How do I get old Git in Visual Studio?

Go to Tools > Options > Environment > Preview Features and then toggle the New Git user experience checkbox, which will switch you back to Team Explorer for Git." According to Git for Visual Studio 2022, For Visual Studio 2022, the new Git Experience is the only Git experience.

How do I get the latest version of Git in Visual Studio?

Visual Studio uses the Sync view in Team Explorer to fetch changes. Changes downloaded by fetch aren't applied until you Pull or Sync the changes. In Team Explorer, select the Home button and choose Sync. In Synchronization, select Fetch to update the incoming commits list.


1 Answers

In Visual Studio 2015, if you do View History (from the Actions menu on the Changes panel in Team Explorer):

View History

Then right click on the commit you're interested in:

Right Click

You can create a branch from there:

New branch

I cannot see a way to just checkout to the commit in Visual Studio.


Working with the command line you can do a checkout of the commit SHA you want to use:

git checkout 9eab01d9 

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 

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.

like image 95
DaveShaw Avatar answered Sep 29 '22 04:09

DaveShaw