Going through the process of getting Visual Studio 2017 installed on all my machines has been pretty smooth. The new installer works great and makes it much clearer what needs to be installed.
The one issue I have had, which was only an issue on one install, is an error when trying to clone a repo from GitHub. I say GitHub but really it would be a problem with any Git repo. The following is the error I was getting.
Error encountered while cloning the remote repository: Git failed with a fatal error.
After searching I found a lot of things to try. I uninstalled and reinstalled Git for Windows multiple times using both the Visual Studio Installer and the stand alone installer. I finally stumbled onto this forum thread which had a solution that worked for me. The following is a quote of the reason for the issue and a fix posted by J Wyman who is a software engineer for Microsoft’s Developer Division.
After intensive investigation we were able to determine that Git was accidentally loading an incorrect version of libeay32.dll and ssleay32.dll due to library loading search order and precedence rules. Multiple users have confirmed that copying the binaries from the “<VS_INSTALL>\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin\” folder to the “<VS_INSTALL>\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\libexec\git-core\” folder completely resolved the issue for him.
Any other users seeing similar problem should attempt the same solution.
I hope this gets other people up and running as it did me. My only worry about this fix is what happens with Git gets updated.
At times I will make some quick changes to a project in Visual Studio to try something out knowing that I will undo the changes when done. Most of the time this works great with no problems, but a few times I am unable to get Visual Studio to undo the changes. Fist I am going to review the steps I normally use to undo and then I will cover the steps I use when files refuse to be undone. Just to be clear I am using Git base source control.
Normal undo changes
Normally when I am ready to undo a set of changes I open the Team Explorer window and select Changes from the drop down at the top of the window. Next I right click on the file, files, or directory I want to undo changes on and click Undo Changes.
This show a message box asking for confirmation before undoing the changes. Click Yes to undo the changes.
If all goes well the select files and/or directory will have reverted and no longer have any changes.
Undo failed now what?
If you undo didn’t clear the changes as expected now what? Well the best answer I have found is to open a command prompt and navigating to the directory that contains the file that needs to be undone and then run the following command. In this example the changes to gulpfile.babel.js will be undone. This will work for both added and changed files.
git checkout gulpfile.babel.js
If you want to undo all the changes in a branch it takes a couple of commands. This first command will remove all changes to tracked files including staged files.
git reset --hard
Next if you have any files that were added (or not already tracked by Git) the following command will remove them.
git clean -f
Your repo will be back to its starting state as if it had just been cloned.
When using the above commands be careful as any changes will be gone and Git will have no record of them. For added files the file will be removed and again Git will have no record of the file. This mean these operations are permanent and should be used with a great deal of caution.
Last week I mentioned adding a .gitignore file to keep a configuration file from causing issues across machines. Visual Studio make it super easy to add, but the next time I made a change to the project the configuration file showed up in my changes again. Turns out that if Git is already tracking a file adding it to the ignore file will not do anything. I am going to walk through adding an ignore file and then cover the one of the processes that can be used to stop Git from tracking files that are in your ignore file.
Using Visual Studio to add a .gitignore file
Inside of Visual Studio open the Team Explorer window. If you don’t already have it open use the quick launch in the upper right hand side of the window to search for it. If it is not already on the Home page click the house icon in the top of the Team Explorer window.
Click the settings option.
Then click Repository Settings.
Now click the add link next to the Ignore File description. This will add the .gitignore file will all the defaults set for things that should be ignored. You could add the file manually, but then you would not get the nice set of default values. If you do decide to add the file manually this repo contains all the defaults that should be ignored for a project using .NET/Visual Studio.
Now that the file exists check it in.
Stop tracking files that should be ignored
To stop tracking the files in the ignore file open a command prompt and navigate to the directory that contains your solution file (.sln) and run the following commands.
git rm -r --cached .
git add .
git commit -am "Remove ignored files"
That seemed to do the trick for me. The git commands I found here. If you click on that link you will see there are lots of options on which commands to use for this process. If the above doesn’t work for you one of the other answers should meet your needs.
In the future I will be making sure my ignore file exists first just to avoid any issues.