VS – github – creating a branch and a pull request using the command line

I have predominately used TFVC for so long that the git workflow is still a little fuzzy to me, so I am writing this post for myself to better understand git.

So, I started off trying to use Visual Studio and the cmd command shell.

I already have my git repository created FSharpAPI1. I have it connected to a remote repository on GitHub as well.

I started off with a push command to get things back in sync (I been working on this repo locally). I had a strange issue using the cmd shell to push to the remote repository. Apparently there was some issue with the Credential Manager git was using on Windows.

The request was aborted: Could not create SSL/TLS secure channel.

error in credential log

So I decided to reinstall git, and use Git Bash for Windows instead of cmd. The shell is very nice looking and allows me to use basic Linux commands like grep, alias, and ls to improve my workflow..

Creating the Branch
I used the git branch command to create a new branch called cleanup-comments-cap3

$ git branch cleanup-comments-cap3

I find it interesting that git doesn’t give you any success message that the branch has been created; we can, however, confirm that the new branch was successfully created using the git branch -all command. This command will list all branches locally and remote.

Next I execute the checkout command to switch to the new branch

git checkout cleanup-comments

What is kind of neat is that executing these changes in the command line are automatically visible in Visual Studio. Here in the below screenshot, my new branch has been checked out, and is now selected in Team Explorer

new branch appears in Team Explorer in Visual Studio (using git plugin VS 2017)

Creating the Pull Request
a Pull Request is functionality that is specific to github, not git, so in order to create an actual github pull request ( I wanted to do all of this on the command line), I had to download the Windows version of this command line tool here. https://github.com/github/hub

To downloado the hub tool, I first had to install the scoop Windows package manager using the following command in powershell..

iex (new-object net.webclient).downloadstring('https://get.scoop.sh')

This plugin allows me to now use the following command to create a pull request (Do not forget to push your changes to the remote origin first)

hub pull-request

Beautiful, the pull request has now appeared online in github…

my pull request created with the command line