安装GitHub for Windows是一种同时获得初学者的git Windows应用程序、msysgit和posh-git的好方法,但你只能通过调用"GitHub.appref-ms --open- shell“来启动带有posh-git的git shell。
我想做的是启动一个控制台,加载powershell,并使用Github for Windows附带的posh-git -但我想不出一种方法将其加载到powershell中。
更新:我不想单独安装Git for Windows,因为已经安装了msysgit。
通过调用AppData\Local\Github文件夹中的shell1.ps1脚本,我取得了一些进展-它确实允许我调用git。但它没有显示我所在的分支,与GitHub for Windows的"Git Shell“相反。
发布于 2012-09-21 13:34:28
尽管@dahlbyk answer没有提供解决方案,但它仍然将我推向了正确的方向。问题是,Phil's Haack博客文章中引用的$env:posh-git环境没有定义,所以在PowerShell配置文件脚本中测试它不会做任何事情。
不过,从同一个脚本运行shell.ps1和profile.example.ps1是可行的。下面是像我这样的PowerShell新手的食谱:
。(解析-路径"$env:LOCALAPPDATA\GitHub\shell.ps1")。$env:github_posh_git\profile.example.ps1
发布于 2012-09-21 09:33:38
在http://haacked.com/archive/2012/05/21/introducing-github-for-windows.aspx中,将以下内容放入您的个人资料中,以便从GitHub for Windows加载posh-git:
# If Posh-Git environment is defined, load it.
if (test-path env:posh_git) {
. $env:posh_git
}发布于 2015-11-28 05:07:19
Following these directions,要在powershell中安装和使用Posh-git,请执行以下操作:
对您选择的directory
git clone git://github.com/dahlbyk/posh-git.git:Set-ExecutionPolicy RemoteSignedSet-ExecutionPolicy Unrestricted
cd posh-git.\install.ps1. $PROFILE我最初遵循流行的haacked.com教程中给出的指导(正如@dahlbyk和@CB指出的那样),但遇到了与OP类似的问题。
https://stackoverflow.com/questions/12504649
复制相似问题