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.
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:
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:
When you are done, just check out master again:
You might get warnings about working on a detached head, in that case you could create a branch temporarily:
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.
(This works in both VS2015 and VS2017.)
I believe this is the simplest way:
Now you can do whatever you want to do with that file, and then undo the pending change when you're done.
To keep your entire solution at the latest, but use an older version of an individual file:
Using Visual Studio 2015 Update 3:
You will now have the latest of every file in the repository except for the file that you just undid the changes on. You could now reset mixed again on the latest commit to see only the one file that you are using the old version of in Team Explorer → Changes, but if all you're trying to do is run the solution, this step is unnecessary.
To reset the entire solution/source repository to a specific commit:
Using Visual Studio 2015 Update 3:
Right-click on the desired commit and select Reset → Reset and Delete Changes (--hard). . In Team Explorer → Sync and then in the View History window, you will end up with incoming commits from the desired commit to the latest commit in the remote branch, and your local code will match the desired commit.
When you're done, perform a pull in Team Explorer → Sync to bring your local branch to the remote branch's latest commit.