How to Install Posh-Git on Windows

posh-git is a PowerShell module that enhances your command line experience by displaying Git status information and providing tab completion for Git commands.

This guide will show you how to install Posh Git on Windows using the Chocolatey Package Manager.

As an afterthought, I’ve added notes at the end for showing latest alternative install methods, and some prerequisites info.

Installing Posh-Git

If you already have Chocolatey installed, you can install posh-git with a single command:

# install poshgit with choco 
choco install poshgit
install poshgit example powershell

Once installed, restart your PowerShell session or reload your profile to activate posh-git.

How Posh-Git Looks

After install, navigate to a Git repository using PowerShell. You’ll see the Git branch and status in your prompt, making it easy to track your changes.

Below is a quick demo of it working – I’m creating a new branch, creating a new text file and staging the file:

posh git small example
posh git example

This looks better in Windows Terminal! It’s an older post this is.

Additional Notes for Installing posh-git

Prerequisites

> PowerShell Version:
Windows PowerShell 5.x or PowerShell Core 6.x+powershell:

# check powershell version 
$PSVersionTable.PSVersion 

> Execution Policy:
Must be set to RemoteSigned or Unrestricted. Update if needed:

# set remote execution policy to current user
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm

> Git Installed:
Ensure Git is installed and accessible:

# show git version installed
git --version

Alternative Installation Methods

> PowerShell Gallery:

# First-time installation
Install-Module posh-git -Scope CurrentUser -Force
# Update existing version
Update-Module posh-git

> Scoop:

scoop bucket add extras
scoop install posh-git
Add-PoshGitToProfile

> Manual Installation:
Clone the repository and import the module:

Import-Module <path-to-src\posh-git.psd1>

That’s it for getting started with posh-git, I hope this guide was useful and what you were looking for.

Bonus Tip:
Change your posh-git theme by installing oh-my-posh, check out my other post for more info!


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *