git - 使用 http://username:password@server 的 Git Pull 仍然要求提供凭据?
问题描述
我有以下脚本,它从文件中加载凭据并使用凭据嵌入的 URL 格式进行拉取。
$remote = "http://server/repo.git"
$credential = Import-CliXml -Path 'gitcreds.xml'
Write-Host "Using credentials for $($credential.UserName)"
$url = $remote
$url = $url.Replace("http://","http://$($credential.UserName):$($credential.GetNetworkCredential().Password)@")
$url = $url.Replace("https://","https://$($credential.UserName):$($credential.GetNetworkCredential().Password)@")
Write-Host "Pulling from $($url)..."
git pull $url -f -q --progress --recurse-submodules
我正在使用它来生成凭证文件:
$credname = Read-Host "Name for the credential file? (include .xml)"
$credential = Get-Credential
$credential | Export-CliXml -Path $credname
输出更新的调试行$url
看起来与我期望的完全一样 ( Pulling from http://gituser:password@server/repo.git...
),但我仍然收到 Windows 凭据提示。为什么会发生,我该如何避免?
解决方案
推荐阅读
- node.js - 从 Node 中的级别 db 返回数据时,Hapijs 抛出“无法抛出非错误对象错误”
- mfc - 如何在 CDHtmlDialog 中加载 html 文本?
- c# - 将多个类序列化和反序列化为一个 JSON 对象?没有属性标签
- mockito - Mockito 错误地(?)因可变类的 TooManyActualInvocations 而失败
- mysql - 为什么我的 MySQL 查询很慢?
- mariadb - MariaDB - 使一列对另一列唯一
- python - 将 flask.Response 转换为 requests.Response
- android - 如何创建这种类型的按钮?
- scala - Spark - 需要改进代码以修复 OutOfMemoryError:Java 堆空间?
- javascript - 纯JS中的两种方式数据绑定?