问题描述
我在azure构建管道中配置了powershell任务,以将来自dev的更改合并到我的github公共仓库的master中,并将更改推送到master.我正在
I have powershell task configured in azure build pipelines to merge changes from dev into master of my github public repo and push changes to master. I am getting
注意:
- 我已经用我的用户名和emailid配置了gitconfig.
- 当我在文件中进行修改并进行提交和推送时,git push可以正常工作,但是当我进行合并和推送时,它会抛出此错误
- 我有足够的特权来推动分支机构
在此方面的任何帮助将不胜感激.如果需要更多信息,请在此线程中进行评论.
Any help on this would be much appreciated. In case of more information needed, comment in this thread.
这是实际的代码段.
$branchName = $env:BRANCH_NAME;
Write-Host "Getting SHA for last commit in the latest release" -ForegroundColor Blue;
$latestReleaseCommitSHA = git rev-list --tags --max-count=1;
if([string]::IsNullOrEmpty($latestReleaseCommitSHA)) {
Write-Host "Unable to get the SHA for last commit in latest release" -ForegroundColor Red;
EXIT 1;
}
Write-Host "SHA for last commit in the latest release is '$($latestReleaseCommitSHA)'" -ForegroundColor Green;
Write-Host "Merging Changes till '$($latestReleaseCommitSHA)'" -ForegroundColor Blue;
git merge $latestReleaseCommitSHA
Write-Host "Checking Conflicted Files";
$conflictedFiles = git diff --name-only --diff-filter=U
if (-Not [string]::IsNullOrEmpty($conflictedFiles)) {
Write-Host "Unable to Merge" -ForegroundColor Red;
Write-Host "There are conflicts in below files:" -ForegroundColor Cyan;
Write-Host -Object $conflictedFiles -ForegroundColor Cyan;
EXIT 1;
}
Write-Host "Merged changes to '$($branchName)'" -ForegroundColor Green;
Write-Host "Pushing changes." -ForegroundColor Blue;
git push origin HEAD:$branchName
Write-Host "Pushed the changes to the $($branchName) branch." -ForegroundColor Green;
推荐答案
我不为什么,但是当您在merge
git之后尝试push
时,想要用户名&密码.
I don't why but when you try push
after merge
git want the username & password.
默认情况下,Azure DevOps禁用提示输入凭据的提示,并且您收到错误消息.
Azure DevOps by default disable the prompt to enter the credentials and you got the error.
您可以通过将环境变量GIT_TERMINAL_PROMPT
设置为1
来启用提示,但是在构建期间,您无法输入值,并且构建将挂起.
You can enable the prompt by set the environment variable GIT_TERMINAL_PROMPT
to 1
but during the build you can't enter the values and the build will hang.
要解决该错误,只需添加用户名&密码或git push
命令中的个人访问令牌(PAT):
To fix the error, just add the username & password or the Personal Access Token (PAT) in the git push
command:
git push https://username:password(or PAT)@github.com/username/reponame.git
https://...
替换origin
.
这篇关于Azure管道:我越来越致命:无法读取"https://github.com"的用户名:终端提示已禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!