致命:无法读取Visual Studio的用户名<url>:没有此类设备或地址

时间:2018-05-09 09:01:03

标签: git version-control azure-devops

任何人都可以帮助我解决以下问题吗?我在詹金斯面对它。

+ git commit -m Added file
[PROD-Backup-NHS 9d4222d] Added file
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 newfile1
+ git push -u origin PROD-Backup-NHS
fatal: could not read Username for 'https://nestle-globe.visualstudio.com': 
No such device or address
Build step 'Execute shell' marked build as failure
Finished: FAILURE

使用的其他命令:

git branch -a
git checkout PROD-Backup-NHS
touch newfile1
ls -lrt ${WORKSPACE}
git config --global user.email "user.name@nestle.com"
git config --global user.name "user name"
git add .
git commit -m "Added file"
git push -u origin PROD-Backup-NHS

1 个答案:

答案 0 :(得分:1)

推送到VSTS git repo时,您需要提供凭证。 可以在repo URL中添加PAT或备用凭证:

选项1:在VSTS git repo URL

中添加PAT

网址格式应为:

https://Personal%20Access%20Token:{PAT}@nestle-globe.visualstudio.com/{projectname}/_git/{reponame}

选项2:在VSTS git repo URL

中添加备用凭证

网址格式应为:

https://{secondary username}:{password}@nestle-globe.visualstudio.com/{projectname}/_git/{reponame}

当您将VSTS git repo添加为本地git仓库的远程(origin时,您需要使用:

git remote add origin https://Personal%20Access%20Token:{PAT}@nestle-globe.visualstudio.com/{projectname}/_git/{reponame}

或者

git remote add origin https://{secondary username}:{password}@nestle-globe.visualstudio.com/{projectname}/_git/{reponame}

由于现在origin网址不包含凭据。如果您不想更改原始网址,可以按以下任何命令进行操作:

git push -u https://Personal%20Access%20Token:{PAT}@nestle-globe.visualstudio.com/{projectname}/_git/{reponame} PROD-Backup-NHS
git push -u https://{secondary username}:{password}@nestle-globe.visualstudio.com/{projectname}/_git/{reponame} PROD-Backup-NHS