I’m starting to automate loading different scripts into source control on a regular schedule (more on that to come!). We are 100% GIT where I work, so I wanted to hook Git into PowerShell.

To use GIT in PowerShell you have a couple of options like https://github.com/dahlbyk/posh-git for example but I found the easiest was to simply use the GIT command line from PowerShell to do that you simply need to do the following:

Download git for Windows:
https://git-for-windows.github.io/

Update Environment variable with:
C:\Program Files\GIT\bin

GITviaPowerShell01

Scroll down to the “Path” variable in System Variables

GITviaPowerShell02

Select Edit (Windows Server 2012r2 and below) and add a new the path via

“;C:\Program Files\Git\Bin”

In windows 10 they have made it a bit nicer and give you the option to easily add a new path with selecting New

GITviaPowerShell03

Select Ok when your down and open up Powershell! Now you can use GIT command from Powershell

GITviaPowerShell04

Advertisements