问题描述
我试图使用linux将整个存储库克隆到我的机器上。我用
git clone< url>
然后我进入下载并键入的文件夹
$在终端中b $ b
git分支
它只向我显示主人,而不是显示在远程存储库中的其他分支。我如何克隆所有分支?
我知道,对于远程中的每个分支,我可以单独使用
git checkout -b<本地分支的名称>起源/<远程分支的名称>
但是除此之外还有其他方法吗?
touch getAllBranches.sh
getAllBranches.sh
(2)将以下内容插入 getAllBranches.sh
file:
用于`git branch中的分支-a | grep远程| grep -v HEAD | grep -v master`; do
git branch --track $ {branch#remotes / origin /} $ branch
done
(3)获取所有分支:
chmod + x getAllBranches.sh
sh getAllBranches.sh
(4)检查本地存储库的结果:
git branch
例如,我使用repository: p>
I'm trying to clone an entire repository onto my machine using linux. I used
git clone <url>
I then went into the folder where it was downloaded and typed
git branch
in the terminal. It's only showing me master and not other branches which were in the remote repository. How do I clone all branches?
I know that for each branch in the remote I can separately use
git checkout -b <name of local branch> origin/<name of remote branch>
but is there any way other than that?
(1) Inside git local repostitory, create a new sh file
touch getAllBranches.sh
vi getAllBranches.sh
(2) Insert the below content to getAllBranches.sh
file:
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master `; do
git branch --track ${branch#remotes/origin/} $branch
done
(3) Get all branches:
chmod +x getAllBranches.sh
sh getAllBranches.sh
(4) Check result at local repository:
git branch
For example, I use repository: https://github.com/donhuvy/spring-boot
As you can see, I have been fetched all branches to local machine:
这篇关于Git Hub一次克隆所有分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!