我克隆了一个包含许多分支的Git存储库。然而,git分支仅显示一个:
$ git branch
* master
我如何在本地拉所有分支,所以当我执行git分支时,它会显示以下内容?
$ git branch
* master
* staging
* etc...
我克隆了一个包含许多分支的Git存储库。然而,git分支仅显示一个:
$ git branch
* master
我如何在本地拉所有分支,所以当我执行git分支时,它会显示以下内容?
$ git branch
* master
* staging
* etc...
当前回答
对于Visual Studio用户,在包管理器控制台上:
git branch | %{ git fetch upstream; git merge upstream/master}
其他回答
我们可以将所有分支或标记名称放在一个临时文件中,然后对每个名称/标记执行git pull:
git branch -r | grep origin | grep -v HEAD| awk -F/ '{print $NF}' > /tmp/all.txt
git tag -l >> /tmp/all.txt
for tag_or_branch in `cat /tmp/all.txt`; do git checkout $tag_or_branch; git pull origin $tag_or_branch; done
使用git fetch和git checkout RemoteBranchName。
这对我来说很好。。。
玩git时要小心,循序渐进。
$ git remote update //This will update your local
$ git branch -a //This will list all the branches(After updating you can now
see the new branch in the list)
$ git checkout your_branch_name
我用这个命令拉动原点分支,git拉动原点
确保所有远程分支都可以在.git/config文件中获取。
在本例中,只有原始/生产分支是可获取的,即使您尝试执行git fetch,除了获取生产分支之外,一切都不会发生:
[origin]
fetch = +refs/heads/production:refs/remotes/origin/production
该行应替换为:
[origin]
fetch = +refs/heads/*:refs/remotes/origin/*
然后运行git fetch等。。。