我刚刚尝试通过复制并粘贴以下命令从 PowerShell 库安装 Posh-Git:
Install-Module -Name posh-git -RequiredVersion 0.7.1
该命令似乎运行良好,即有轻微的延迟,并且我的 PowerShell 提示符返回。没有成功或错误消息,但我在 Git 文件夹中仍然没有特殊的 Posh-Git 提示符,并且文件夹C:\Users\brady\Documents\WindowsPowerShell\Modules
是空的,这意味着没有安装任何模块。
根据建议,使用-verbose
开关得到以下输出:
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified. PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='posh-git'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'posh-git'.
VERBOSE: Skipping installed module posh-git 0.7.1.
然后检查$error
变量得到以下输出:
Unable to find type [Microsoft.PowerShell.Commands.PowerShellGet.Telemetry].
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:715 char:26
+ ... yMethods = ([Microsoft.PowerShell.Commands.PowerShellGet.Telemetry] | ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Microsoft.Power...llGet.Telemetry:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
答案1
听起来你不认识 Posh-Git 的要求或者你没有使用以下方式导入 Posh-GitImport-Module
例子:
PS C:\Users\user\Documents\code\Office365> #See no special git info
PS C:\Users\user\Documents\code\Office365> Import-Module posh-git
C:\Users\user\Documents\code\Office365 [develop ↑1 +1 ~0 -0 !]>