Quick Tip: Alias Hub as Git on Windows

If you use Git with GitHub, the Hub wrapper utility by GitHub is a better CLI option for working with your personal and org repositories.

Quick Tip: Alias Hub as Git on Windows

If you use Git with GitHub, the Hub wrapper utility by GitHub is a better CLI option for working with your personal and org repositories. In addition to all of the standard git commands, you gain GitHub-specific ones like fork, pull-request, browse, and many others.

Install Go Dev Environment

  1. choco install golang -y
  2. Add/Set the %GOPATH% environment variable that points to your Go installation bin directory. If installed via Chocolatey, that path is C:\tools\go\bin

Install Hub

  1. go get github.com/github/hub
  2. Add Hub to %Path% environment variable C:\tools\go\bin\bin

Set up your aliases

To save your alias between sessions, you need to do a bit more setup, depending on your preferred shell.

POWERSHELL

  1. Find your default profile. The fastest way is to open a Powershell window and use the following command Get-Variable profile. This will return something like c:\Users\myname\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
  2. Edit the above file and add the following line Set-Alias git hub. The result should look like the following:

CONSOLE

  1. Create a batch file that will hold the alias command, something like C:\Utils\aliases.bat
  2. Add the following line to the batch file doskey git=hub. The result should look like the following:

You can use your new alias file in a couple of ways, depending on what you want to do.

  1. Just launch cmd.exe with and pass in your new alias file cmd.exe /K c:\Utils\aliases.bat. Now all of your doskey commands will be available in that console session
  2. Add to the registry, so your aliases are automatically available in every console session. Run regedit and go to HKEY_CURRENT_USER -> Software -> Microsoft -> Command Processor. Add a String Value entry with the name AutoRun and the full path of your .bat/.cmd file c:\Utils\aliases.bat. See the entire answer on StackOverflow.

Hub is now Git