受限于工作环境内网加密策略,只能使用http方式拉取gitlab上的仓库,但是由于仓库、分支较多,会存在拉取失败情况,实践比较可行的解决办法如下。
// 如果需要直接切到某个branch下,还是可以用: git clone -b <branch_name>--depth 100 <repo_url>
git clone --depth 100 <repo_url>
// 如果是某些企业内网限制只能使用http协议clone,使用git bash命令行会遇到:http is not support的错误,
// 这时候可以简单切换到power shell等其他命令行绕开限制即可
// 注意!!这里要切到有对应项目.git文件夹所在的目录下:比如工程名是my_project,那么.git文件夹就是在my_project/.git路径
// 这里就是要切到my_project文件夹下。
// 说的有点饶了,其实git clone后直接cd my_project就好啦!
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git remote update
// 至此问题完美解决~
如果git remote update
还会报因为分支太多EOF的错误,还可以使用单独拉需要的分支办法解决:
使用单独拉需要的分支办法解决:
git fetch origin 远程分支名:本地分支名
// 然后再切到本地分支即可
git checkout 本地分支名
执行以上命令后成功拉取到指定分支: