Load git into PowerShell
By Anatoly Mironov
Just a little productivity tip. If you use git on Windows, you probably already have the Github for Windows application. This application adds the Git Shell:
The Git Shell will open a PowerShell window and execute shell.ps1 from the Github directory:
What it won’t do is to load your personal PowerShell profile. I want to use my PowerShell profile that creates some links and adjust the look-and-feel and the promt of the shell. By the way I have published my profile.ps1 as a gist:
- my profile.ps1
I also want to have git in PowerShell available directly. The answer is in the shell.ps1 in the Github folder:
So add this line to your profile.ps1 as I did:
[source language=“powershell”] . (Resolve-Path “$env:LOCALAPPDATA\GitHub\shell.ps1”) [/source]
That’s it. If you haven’t seen the “DOT” in PowerShell scripts, it is called dot sourcing, it will execute the script and keep all the variables and references within the script.
An alternative
If you do not have Github for Windows, there is another way to load git functionality into PowerShell: