Professional Documents
Culture Documents
About Posh-Git - Help
About Posh-Git - Help
posh-git
SHORT DESCRIPTION
posh-git integrates Git and PowerShell providing tab completion of Git
commands, branch names, paths and more. It also provides Git status
summary information that can be displayed in the PowerShell prompt.
LONG DESCRIPTION
posh-git integrates Git and PowerShell. Tab completion is supported for
Git subcommands, branch and remote names. Git also provides commands to
display colored Git status summary information. If you would like fine
grained control over how the Git status summary information is displayed
in your prompt function, you can get the raw status summary information
via the Get-GitStatus command. Then you can display the information in
your prompt however you would like.
posh-git will install a prompt function if it detects the user does not
have their own, customized prompt. This prompt displays Git status summary
information when the current directory is located in a Git repository.
RELEASE NOTES
See https://github.com/dahlbyk/posh-git/blob/master/CHANGELOG.md
You can also tab complete branch names and even remote names such as
origin and upstream. For instance, type the following inside of a Git
repo to see tab completion in action:
And like tab completion in other parts of PowerShell, you can press tab
multiple times to cycle through all matches. For instance, type
"git ch" and press the tab key multiple times to cycle through "checkout",
"cherry" and "cherry-pick".
POWERSHELL PROMPT
PowerShell generates its prompt by executing a function named "prompt", if
one exists. posh-git will install its prompt function if it detects the
user does not have their own, customized prompt function. The posh-git
prompt displays the current working directory followed by git status
summary information if the current directory is located in a Git
repository, e.g.:
You can customize the posh-git prompt using various settings in the
$GitPromptSettings variable. For details see:
https://github.com/dahlbyk/posh-git/blob/master/README.md#customizing-the-posh-
git-prompt
GIT STATUS SUMMARY
[{HEAD-name} S +A ~B -C !D | +E ~F -G !H W]
* [ (BeforeStatus)
* {HEAD-name} is the current branch, or the SHA of a detached HEAD
* Cyan means the branch matches its remote
* Green means the branch is ahead of its remote (green light to push)
* Red means the branch is behind its remote
* Yellow means the branch is both ahead of and behind its remote
Note: This status information reflects the state of the remote tracked
branch after the last `git fetch/pull` of the remote. Execute
`git fetch` to update to the latest on the default remote repo. If you
have multiple remotes, execute `git fetch --all`.
https://github.com/dahlbyk/posh-git/blob/master/README.md#customizing-the-posh-
git-prompt
PERFORMANCE
Displaying Git status in your prompt for a very large repository can
be prohibitively slow. Rather than turn off Git status entirely, you can
disable it on a repo-by-repo basis by adding individual repository paths
to $GitPromptSettings.RepositoriesInWhichToDisableFileStatus.
PRIMARY COMMANDS
Get-GitStatus:
Returns information about the current Git repository as well as the index
and working directory.
Remove-GitBranch:
Deletes the specified Git branches that have been merged into the commit
specified by the Commit parameter (HEAD by default). You must either
specify a branch name via the Name parameter, which accepts wildard
characters, or via the Pattern parameter, which accepts a regular
expression.
Write-GitStatus:
Given a status object returned by Get-GitStatus, this command formats it
as described above in the GIT STATUS PROMPT section. On a host that
supports virtual terminal sequences and where
$GitPromptSettings.AnsiConsole is set to $true, the prompt text is
returned by the function as a string which may contain ANSI escape
sequences. Otherise, the prompt text is written directly to the host.
Write-VcsStatus:
Gets the Git repository information and formats it, as described
above in the GIT STATUS PROMPT section. On a host that supports virtual
terminal sequences and where $GitPromptSettings.AnsiConsole is set to
$true, the prompt text is returned by the function as a string which
may contain ANSI escape sequences. Otherise, the prompt text is written
directly to the host.
This command can be used with other version control systems that append
a scriptblock, which uses Write-Prompt to supply their prompt text, to
$global:VcsPromptStatuses.