I'm trying to use git on powershell, but having trouble. I was following Miguel Grinberg pycon workshop, and he clones with git clone " " I know I can download git, and can be done with git bash. but I want to do the command on windows powershell. Can it be done outside of gitbash?
3 Answers
If you downloaded git from https://git-scm.com/download/win, then you could choose whether to modify PATH when you installed it:

If you chose "Use Git from Git Bash only", you will not be able to use it in the powershell, unless you add X:\path-to-git-installation\cmd to your PATH manually.
Otherwise, you should have no trouble using git in powershell.
Comments
If you download and install the git client for Windows, it will work in powershell.
https://git-scm.com/download/win
For example:
PS C:\Users\joeyoung> git --version
git version 1.9.5.msysgit.1
PS C:\Users\joeyoung> git clone https://github.com/miguelgrinberg/flask-pycon2015.git
Cloning into 'flask-pycon2015'...
remote: Counting objects: 70, done.
remote: Total 70 (delta 0), reused 0 (delta 0), pack-reused 70
Unpacking objects: 100% (70/70), done.
Checking connectivity... done.
PS C:\Users\joeyoung> dir .\flask-pycon2015
Directory: C:\Users\joeyoung\flask-pycon2015
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 31/08/2015 10:56 templates
-a--- 31/08/2015 10:56 675 .gitignore
-a--- 31/08/2015 10:56 3735 app.py
-a--- 31/08/2015 10:56 3629 guess.py
-a--- 31/08/2015 10:56 1083 LICENSE
-a--- 31/08/2015 10:56 99 README.md
-a--- 31/08/2015 10:56 112 requirements.txt
PS C:\Users\joeyoung>
Comments
As I only need Git.exe, I extract Portable Git to a folder and add the following to my Powershell profile...
# Use the locally installed Git, if available.
$gitExecutable = Get-Command git.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Source
if ($gitExecutable -eq $null) {
$gitExecutable = "$env:USERPROFILE\bin\PortableGit\bin\git.exe"
}
function Invoke-Git {
<#
.Synopsis
Wrapper function that deals with Powershell's peculiar error output when Git uses the error stream.
.Example
Invoke-Git ThrowError
$LASTEXITCODE
#>
[CmdletBinding()]
param(
[parameter(ValueFromRemainingArguments=$true)]
[string[]]$Arguments
)
& {
[CmdletBinding()]
param(
[parameter(ValueFromRemainingArguments=$true)]
[string[]]$InnerArgs
)
&$gitExecutable $InnerArgs
} -ErrorAction SilentlyContinue -ErrorVariable fail @Arguments
if ($fail) {
$fail.Exception
}
}
Set-Alias -Name git -Value Invoke-Git
Set-Alias -Name git.exe -Value Invoke-Git