You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure部署Node.js应用报错求助:git push azure master主机解析失败

解决Git Push到Azure时的主机解析错误

这个问题的核心是你的用户名(lalit@wittyparrot.com)里包含了@符号,直接写在HTTPS格式的Git远程URL中时,Git会把@后面的wittyparrot.com误判为主机名的一部分,而实际正确的主机应该是node-deploy-to-azure.scm.azurewebsites.net,这就导致了无法解析主机的错误。

解决步骤:

  1. 先确认当前的远程仓库配置
    执行以下命令查看你的Azure远程仓库URL:

    git remote -v
    

    你会看到类似这样的错误格式:

    azure  https://lalit@wittyparrot.com@node-deploy-to-azure.scm.azurewebsites.net/node-deploy-to-azure.git (fetch)
    azure  https://lalit@wittyparrot.com@node-deploy-to-azure.scm.azurewebsites.net/node-deploy-to-azure.git (push)
    
  2. 修正远程仓库URL
    有两种简单的方法:

    • 方法一:用Git命令转义特殊字符
      URL中的@需要转义为%40,执行以下命令修改远程URL:
      git remote set-url azure https://lalit%40wittyparrot.com@node-deploy-to-azure.scm.azurewebsites.net/node-deploy-to-azure.git
      
    • 方法二:手动编辑Git配置文件
      打开项目根目录下的.git/config文件,找到[remote "azure"]部分,将url字段修改为转义后的版本,或者直接写成不带用户名的格式:
      [remote "azure"]
          url = https://node-deploy-to-azure.scm.azurewebsites.net/node-deploy-to-azure.git
          fetch = +refs/heads/*:refs/remotes/azure/*
      
      这样下次执行git push azure master时,Git会弹出提示让你输入完整的用户名(lalit@wittyparrot.com)和Azure部署凭据的密码。
  3. 验证修改并重新推送
    再次执行git remote -v确认URL已修正,然后尝试推送:

    git push azure master
    

额外提示:

如果还是遇到认证问题,记得检查你的Azure部署凭据是否正确——你可以在Azure门户的App Service资源中,进入「部署中心」>「部署凭据」页面查看或重置密码。

内容的提问来源于stack exchange,提问作者Leo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:19:36