假设我们正在搜索release / 1.0.5
如果git fetch -all
是不工作,并且您不能看到远程分支和git branch -r
不显示这个特定分支。
1.从远程打印所有裁判(分支,标签等):
git ls-remote origin
应该向您显示您正在搜索的远程分支。
e51c80fc0e03abeb2379327d85ceca3ca7bc3ee5 refs/heads/fix/PROJECT-352
179b545ac9dab49f85cecb5aca0d85cec8fb152d refs/heads/fix/PROJECT-5
e850a29846ee1ecc9561f7717205c5f2d78a992b refs/heads/master
ab4539faa42777bf98fb8785cec654f46f858d2a refs/heads/release/1.0.5
dee135fb65685cec287c99b9d195d92441a60c2d refs/heads/release/1.0.4
36e385cec9b639560d1d8b093034ed16a402c855 refs/heads/release/1.0
d80c1a52012985cec2f191a660341d8b7dd91deb refs/tags/v1.0
新分支'release / 1.0.5'出现在输出中。
2.强制获取远程分支:
git fetch origin <name_branch>:<name_branch>
$ git fetch origin release/1.0.5:release/1.0.5
remote: Enumerating objects: 385, done.
remote: Counting objects: 100% (313/313), done.
remote: Compressing objects: 100% (160/160), done.
Receiving objects: 100% (231/231), 21.02 KiB | 1.05 MiB/s, done.
Resolving deltas: 100% (98/98), completed with 42 local objects.
From http://git.repo:8080/projects/projectX
* [new branch] release/1.0.5 -> release/1.0.5
现在,您在本地也有引用,您可以结帐(或其他方式)该分支。
任务完成!