git/workflow

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

Posted by matteskolin on

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
Visual Studio Tips

Visual Studio Tip: How to Open the same file twice

Posted by matteskolin on

I recently discovered this feature while working on large MS Word documents. In Word, it is possible to open the same file twice, so that the same document appears in two Windows. This is very helpful when you need to reference one part of the document while you are working on another part of the document elsewhere in the file.

Then when working on a large C# file, I wondered if Visual Studio could do the same thing. It turns out it can! With the large file open, click “New Window” under the Window menu.

See example below. I wasn’t sure how to quickly create a large file, and I didn’t spend much time thinking about it, so it is pretty silly. BigClass.cs contains a method that adds the integer 1 to a list thousands of times. On the right at line 82, I have added an important line that the programmer needs to reference later. On the Left, the programmer is working down on line 7736, and is able to reference line 82 in the window on the right. What else is cool is that if you start typing text in one window, the text appears automatically in the other window.