posh-git
Last updated
Last updated
posh-git is a PowerShell module that integrates Git and PowerShell by providing Git status summary information that can be displayed in the PowerShell prompt, e.g.:
posh-git also provides tab completion support for common git commands, branch names, paths and more. For example, with posh-git, PowerShell can tab complete git commands like checkout
by typing git ch
and pressing the tab key. That will tab complete to git checkout
and if you keep pressing tab, it will cycle through other command matches such as cherry
and cherry-pick
. You can also tab complete remote names and branch names e.g.: git pull or<tab> ma<tab>
tab completes to git pull origin master
.
More information can be found at
Open a powershell window by searching for powershell in the start menu or by typing it in the address bar of an explorer window as shown in the screenshot below.
Before installing posh-git make sure the following prerequisites have been met.
PowerShell 5.0 or higher. Check your PowerShell version by executing $PSVersionTable.PSVersion
.
Script execution policy must be set to either RemoteSigned
or Unrestricted
. Check the script execution policy setting by executing Get-ExecutionPolicy
. If the policy is not set to one of the two required values, run PowerShell as Administrator and execute:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm
Git must be installed and available via the PATH environment variable.
Check that git
is accessible from PowerShell by executing git --version
from PowerShell.
If git
is not recognized as the name of a command verify that you have Git installed.
If not, follow the installation guide for Git.
If you have Git installed, make sure the path to git.exe is in your PATH environment variable.
You may be asked if you trust packages coming from the PowerShell Gallery. Answer yes to allow installation of this module to proceed.
After you have installed posh-git, you need to configure your PowerShell session to use the posh-git module.
The first step is to import the module into your PowerShell session which will enable git tab completion. You can do this with the command Import-Module posh-git
. Make sure no errors are reported.
You do not want to have to manually execute the Import-Module
command every time you open a new PowerShell prompt. Let's have PowerShell import this module for you in each new PowerShell session. We can do this executing Add-PoshGitToProfile -AllHosts
to make posh-git available in all your PowerShell hosts (console, ISE, etc).
Open a new powershell window first to make sure that posh-git is being reloaded.
Traverse to a directory where you can create a git test repository. For example your desktop:
Create a directory and initialize a git test repository:
Now if you execute a git status
you should see some posh-git magic as shown below:
All good to go
Execute the command below to install from the :