Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use posh-git that comes with GitHub for Windows from custom shell?

Tags:

Installing GitHub for Windows is a nice way to get at once beginner's git Windows app, msysgit and posh-git - but you can only start the git shell with posh-git by calling "GitHub.appref-ms --open-shell".

What I want to do, is to start a console, load powershell, and use posh-git that comes with Github for Windows - but I can't figure a way to load it into the powershell.

Update: I do not want to install Git for Windows separately, since msysgit is already installed.

I was able to make some progress by calling the shell1.ps1 script from AppData\Local\Github folder - and it does let me invoke git. But it does not display the branch I'm in, opposite to the "Git Shell" from GitHub for Windows.

like image 254
Sergey Aldoukhov Avatar asked Sep 20 '12 00:09

Sergey Aldoukhov


People also ask

Does posh-git work with Git bash?

Git Bash is a package that installs Bash, some common bash utilities, and Git on a Windows operating system. However, it is recommended to use Git with Posh-Git. It's a PowerShell environment for Git. It's an open source project hosted on GitHub.

How do I open the git shell in Windows?

You can also launch the Git Shell from the Desktop GUI application by pressing the ~ key (or CTRL + ~ at any time such as when a text field has focus) or via the gear menu in the top right. Select the “Open in Git Shell” menu item.


1 Answers

Though @dahlbyk answer did not provide resolution, it still pushed me in the right direction. The problem is, $env:posh-git environment referenced in the Phil's Haack blog post is not defined, so testing it in the PowerShell profile script does nothing.

What works though is running shell.ps1 and profile.example.ps1 from the same script. Here is the recipe for PowerShell noobs like me:

  1. Edit or create Microsoft.PowerShell_profile.ps1 in active user's Documents\WindowsPowerShell folder (create the folder if it does not exist)
  2. Add the following 2 lines:

    . (Resolve-Path "$env:LOCALAPPDATA\GitHub\shell.ps1") . $env:github_posh_git\profile.example.ps1 
like image 173
Sergey Aldoukhov Avatar answered Oct 04 '22 01:10

Sergey Aldoukhov