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
choco install golang -y
- Add/Set the
%GOPATH%
environment variable that points to your Go installation bin directory. If installed via Chocolatey, that path isC:\tools\go\bin
Install Hub
go get github.com/github/hub
- Add Hub to
%Path%
environment variableC:\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
- 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 likec:\Users\myname\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
- Edit the above file and add the following line
Set-Alias git hub
. The result should look like the following:
CONSOLE
- Create a batch file that will hold the alias command, something like
C:\Utils\aliases.bat
- 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.
- Just launch
cmd.exe
with and pass in your new alias filecmd.exe /K c:\Utils\aliases.bat
. Now all of your doskey commands will be available in that console session - 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 nameAutoRun
and the full path of your .bat/.cmd filec:\Utils\aliases.bat
. See the entire answer on StackOverflow.