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

Visual Studio 2022无法推送至远程Git仓库:master分支被锁定如何解锁?

解决Visual Studio.com Git仓库master分支被锁定无法推送的问题

当新开发者推送代码至master分支时收到错误提示:

'The reference 'refs/heads/master' cannot be updated because it is locked by Carl Forgey.'

这是因为master分支被设置了锁定状态,只有仓库管理员或分支锁定者能解锁,以下是两种解锁方式:

网页端操作步骤

  • 登录Visual Studio.com,进入对应项目
  • 导航到Repos -> Branches页面
  • 在分支列表中找到master分支,点击分支名称右侧的省略号(更多操作)
  • 选择Unlock branch,确认后即可解除锁定

命令行操作(Azure DevOps CLI)

先确保已安装Azure DevOps CLI并完成登录认证,执行以下命令:

az repos branch unlock --name master --repository <你的仓库名称> --project <你的项目名称> --organization <你的组织URL>

额外建议

解锁后建议配置分支保护策略(比如要求通过Pull Request合并到master、设置审批规则等),避免主分支被随意推送,同时兼顾开发流程的规范性。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.14 20:54:50