Skip to content

Instantly share code, notes, and snippets.

@originalmind
Created November 25, 2013 04:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save originalmind/7636510 to your computer and use it in GitHub Desktop.
Save originalmind/7636510 to your computer and use it in GitHub Desktop.
Set the PortableGit (supplied by GitHub for Windows) path for use in PowerShell console.
# Usage: Call this script from your PowerShell profile:
# & c:\path\to\scripts\set-path-portablegit.ps1
# todo: set GITHUB_ROOT from registry
Set-Variable -Option Constant -Name GITHUB_ROOT -Value ${Env:USERPROFILE}\AppData\Local\GitHub\
# Get the most recently created version of PortableGit
if (!(Test-Path $GITHUB_ROOT)) {
Write-Host Sorry can''t find GitHub path.
exit 1
}
$PortableGitDir = gci $GITHUB_ROOT | where-object { $_.Name -like 'PortableGit*' } | sort CreationTime | select -last 1
if (!(Test-Path $PortableGitDir.FullName)) {
Write-Host Sorry can''t find Portable Git path.
exit 2
}
$PortableGitDirName = $PortableGitDir.FullName
Write-Host Adding Portable Git location to path: $PortableGitDirName
$env:Path += ";$PortableGitDirName\bin;$PortableGitDirName\cmd"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment