我已经在BitBucket克隆,拉取并取出了我的远程git仓库。但我只能得到主分支。我在BitBucket的回购有4个分支:
我找到了两个问题this和that。我按照这些问题中的一些说明进行了操作
当我尝试git branch -a
时,我看不到其他三个分支。
*master
remotes/origin/HEAD -> origin/master
remotes/origin/master
我试过了git checkout origin/fix/cleanup
。我收到了一条错误消息。
错误:pathspec'genin / fix / cleanup`与任何已知文件都不匹配 git。
我尝试了checkout -b
,但又出现了另一个错误。
$ git checkout -b fix/cleanup origin/fix/cleanup
fatal: Cannot update paths and switch to branch 'fix/cleanup' at the same time.
Did you intend to checkout 'origin/fix/cleanup' which can not be resolved as com
mit?
我也尝试过执行oneliner。
for remote in `git branch -r`; do git branch --track $remote; done
但它给了我本地的新分支 origin / HEAD 和 origin / master ,而不是其他3个分支。我的回购发生了什么?
我尝试了git fetch --all
和git pull --all
。他们没有给我任何改变。
答案 0 :(得分:4)
我最终找到了解决办法。我调整了git配置文件。 我改变了
fetch = +refs/heads/master:refs/remotes/origin/master
到
fetch = +refs/heads/*:refs/remotes/origin/*
然后,$ git fetch --all
为改变工作。
Fetching origin
Password for 'https://myusername@bitbucket.org':
remote: Counting objects: 993, done.
remote: Compressing objects: 100% (581/581), done.
Receiving objects: 100% (966/966), 723.76 KiB | 8.00 KiB/s, done.
emote: Total 966 (delta 324), reused 964 (delta 322)Resolving deltas: 0% (0/32
Resolving deltas: 100% (324/324), completed with 21 local objects.
From https://bitbucket.org/myusername/myproj
* [new branch] etc/schema_note -> origin/etc/schema_note
* [new branch] feature/sampledata -> origin/feature/sampledata
* [new branch] fix/cleanup -> origin/fix/cleanup
现在,$ git branch -a
开始列出所有远程分支;
* master
remotes/origin/HEAD -> origin/master
remotes/origin/etc/schema_note
remotes/origin/feature/sampledata
remotes/origin/fix/cleanup
remotes/origin/master
最后,我checkout
为每个分支。
TPP@SITHU /d/xampp/htdocs/myproj (master)
$ git checkout etc/schema_note
Branch etc/schema_note set up to track remote branch etc/schema_note from origin.
Switched to a new branch 'etc/schema_note'
TPP@SITHU /d/xampp/htdocs/myproj (etc/schema_note)
$ git checkout feature/sampledata
Branch feature/sampledata set up to track remote branch feature/sampledata from
origin.
Switched to a new branch 'feature/sampledata'
TPP@SITHU /d/xampp/htdocs/myproj (feature/sampledata)
$ git checkout fix/cleanup
Branch fix/cleanup set up to track remote branch fix/cleanup from origin.
Switched to a new branch 'fix/cleanup'
这是我的最终回购分会名单:
$ git branch -a
etc/schema_note
feature/sampledata
* fix/cleanup
master
remotes/origin/HEAD -> origin/master
remotes/origin/etc/schema_note
remotes/origin/feature/sampledata
remotes/origin/fix/cleanup
remotes/origin/master
答案 1 :(得分:0)
如果您克隆了回购,那么您应该已经拥有所有远程分支。
git的工作方式是存储库的每个副本基本相同。克隆存储库的那一刻,您将获得远程服务器拥有的所有内容,包括所有历史记录。
如果您在一个地方看到分支而不是另一个地方(例如,在一个客户端而不是另一个客户端),那么它只能意味着:
某个位置的本地分支尚未传播到远程服务器
和/或
本地客户端未提取/取消传播的更改
修改强>
实际上,git namespaces可能与此相关吗?