Git fetch未拉取上游stable分支,创建本地分支报错求助
解决无法检出上游stable分支的问题
问题原因
你的本地Git仅拉取到了upstream仓库的master分支,说明upstream远程的fetch配置被限制为只跟踪master分支,导致stable分支未被同步到本地。
解决步骤
- 检查当前upstream的fetch规则:
git config --get-regexp remote.upstream.fetch
若输出为remote.upstream.fetch +refs/heads/master:refs/remotes/upstream/master,则确认是fetch规则限制了分支拉取。
- 修改upstream的fetch配置,使其拉取所有分支:
git config remote.upstream.fetch "+refs/heads/*:refs/remotes/upstream/*"
- 重新拉取upstream仓库的所有分支:
git fetch upstream
- 再次查看远程分支,此时应该能看到
upstream/stable,执行检出命令:
git switch -c stable upstream/stable
内容的提问来源于stack exchange,提问作者Felipe Plets
相关产品推荐
相关产品推荐

