A PowerShell environment for Git
posh-git is a PowerShell module which provides Git/PowerShell integration.
The prompt within Git repositories can show the current branch and the state of files (additions, modifications, deletions) within.
Provides tab completion for common commands when using git.
E.g. git ch<tab>
--> git checkout
ssh-agent
wrappers: Get-SshAgent
, Start-Ssh-Agent
, Stop-SshAgent
Update-AllBranches
See profile.example.ps1
as to how you can integrate the tab completion and/or git prompt into your own profile.
Prompt formatting, among other things, can be customized using $GitPromptSettings
, $GitTabSettings
and $TortoiseGitSettings
.
Note on performance: displaying file status in the git prompt for a very large repo can be prohibitively slow. Rather than turn off file status entirely, you can disable it on a repo-by-repo basis by adding individual repository paths to $GitPromptSettings.RepositoriesInWhichToDisableFileStatus
.
Verify you have PowerShell 2.0 or better with $PSVersionTable.PSVersion
Verify execution of scripts is allowed with Get-ExecutionPolicy
(should be RemoteSigned
or Unrestricted
). If scripts are not enabled, run PowerShell as Administrator and call Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm
.
Verify that git
can be run from PowerShell. If the command is not found, you will need to add a git alias or add %ProgramFiles%\Git\cmd
to your PATH environment variable.
Clone the posh-git repository to your local machine.
From the posh-git repository directory, run .\install.ps1
.
Enjoy!
PowerShell generates its prompt by executing a prompt
function, if one exists. posh-git defines such a function in profile.example.ps1
that outputs the current working directory followed by an abbreviated git status
:
C:\Users\Keith [master]>
By default, the status summary has the following format:
[{HEAD-name} +A ~B -C !D | +E ~F -G !H]
{HEAD-name}
is the current branch, or the SHA of a detached HEAD
+
= Added files~
= Modified files-
= Removed files!
= Conflicted filesgit status
, index status is dark green and working directory status is dark redFor example, a status of [master +0 ~2 -1 | +1 ~1 -0]
corresponds to the following git status
:
# On branch master
#
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: this-changed.txt
# modified: this-too.txt
# deleted: gone.ps1
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: not-staged.ps1
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# new.file