Saturday, April 22, 2017

.NET Literacy Day 1: Git / GitHub

Configuration Day: Git, Visual Studio 2017 and GitHub

Visual Studio 2017 has built-in support for Git and TFS. The tutorial talks about how to set up Git for your project. I don't even remember being asked to configure it. Either way, it automatically created a local git repo for my first project. I want my code to live in GitHub for safekeeping (and sharing). I found this stack overflow question that  appeared to have the commands I needed.


git init --bare repo.git
git push --mirror ssh://yourserver/~/repo.git

I had trouble authenticating on the remote GitHub repo from CMD.EXE. GitHub complained about validation because I didn't have the ssh agent running in the background to serve up the ppk key. I actually took care of this exact problem for a project, but I can't remember the ssh command to host the key (Did I do it from BASH? Probably...). I remember finding a lot of information on this topic before, but I also remember that SSH from DOS is a pain, so I abandoned this approach for some Windows-based tools.

GitHub

I started by creating the remote repo on GitHub. The landing screen contained a lot of useful information, including how to push an existing repository from the command line. I wasn't familiar with the --bare or --mirror options from stack overflow.The instructions from BitBucket looked a lot more familiar:

git remote add origin git@github.com:brienmalone/vidly.git
git push -u origin master

But... given the difficulty I was having with authentication from the command line, I opted to install some native Windows tools to help me out.

Git Tools for Windows

I'm not sure if Command-line Git was installed by Visual Studio, or if I did it at some point, but Git was available on the command line. (I'm working on a brand new laptop and don't remember installing it.) I have used Subversion and TortoiseSVN for source control for years, so I installed TortoiseGit for its familiar interface. I needed the putty keygen and pageant to serve the ssh key, so I installed PuTTY for Windows. Finally, I also installed Atlassian SourceTree, which is a very nice, free GUI. (Atlassian has its own cloud git service called BitBucket, which is nice, but I am sticking with GitHub for its ubiquity.)

Pageant

There are plenty of tutorials that explain how pageant works, so I won't go into detail here. In a nutshell, I run pageant, add my PPK key (created with the PuTTY keygen), install the openSSH version of the same key on BitBucket and I'm off and running with whatever tools I want to use (except CMD LOL).



No comments:

Post a Comment