看不到远程分支,.git/config 有问题吗?

Car*_*ton 3 git branch config

由于某种原因,我看不到我的团队已输入的新分支,我 99% 确信该分支存在,因为我可以在 Bitbucket 的 UI 中看到它。

我有一种感觉,可能是因为我的 .git/config 文件不正确。

此刻我有这个...

[remote "origin"]
    url = git@bitbucket.org:user/project.git
    fetch = +refs/heads/master:refs/remotes/origin/master
    fetch = +refs/heads/testing:refs/remotes/origin/testing
    fetch = +refs/heads/uat:refs/remotes/origin/uat
    fetch = +refs/heads/release-1.9:refs/remotes/origin/release-1.9
Run Code Online (Sandbox Code Playgroud)

我尝试过“git远程更新”和“git fetch origin”,但都无法获取新分支

我记得在这里“加注”问题我看不到我的远程分支,并将我的配置更改为旧笔记本电脑上的以下内容

git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
Run Code Online (Sandbox Code Playgroud)

我真的很想知道我的配置文件处于当前状态的根本原因...也许我没有以正确的方式创建分支?

一般来说,当创建新分支时,我会做类似的事情

git checkout -b issue-1001
Run Code Online (Sandbox Code Playgroud)

然后下面分享我的分支

git push origin issue-1001
Run Code Online (Sandbox Code Playgroud)

Joh*_*ter 5

fetch您现有的 refspec 仅获取mastertestinguatrelease-1.9。因此,推送到远程存储库的任何其他分支都会被忽略,并且永远不会被带到本地存储库。您笔记本电脑上的参考规格:

+refs/heads/*:refs/remotes/origin/*
Run Code Online (Sandbox Code Playgroud)

表示从远程存储库获取所有分支,因此任何新分支都对您可见。

简而言之,如果您想查看新分支,那么您需要使用像上面这样的 refspec。

顺便说一句,您创建分支的方式看起来不错。:-)