如何克隆Git中的所有远程分支? [英] How to clone all remote branches in Git?
问题描述
我有一个 master
和一个开发
分支,它们都被推送到 GitHub 。我有 clone
d, pull
ed, master
分支之外的任何其他内容。
我确定我'我错过了一些显而易见的东西,但是我已经阅读了手册,并且我没有得到任何喜悦。 解决方案
首先,克隆一个远程 Git 存储库和 接下来,看看您的存储库中的本地分支机构: 但还有其他分支隐藏在你的仓库中!您可以使用 如果您只想快速查看上游分支,可以直接查看它: 但是如果你想在那个分支上工作,你需要创建一个本地跟踪分支,它可以自动完成: 您会看到 最后一行引出一些人:New分支 - 嗯? 现在,如果你看看你的本地分支,这就是你会看到的: 实际上,您可以使用 在这一点上,事情变得非常疯狂,所以运行 I have a I'm sure I'm missing something obvious, but I have read the manual and I'm getting no joy at all. First, clone a remote Git repository and cd into it: Next, look at the local branches in your repository: But there are other branches hiding in your repository! You can see these using the If you just want to take a quick peek at an upstream branch, you can check it out directly: But if you want to work on that branch, you'll need to create a local tracking branch which is done automatically by: and you will see That last line throws some people: "New branch" - huh?
What it really means is that the branch is taken from the index and created locally for you. The previous line is actually more informative as it tells you that the branch is being set up to track the remote branch, which usually means the origin/branch_name branch Now, if you look at your local branches, this is what you'll see: You can actually track more than one remote repository using At this point, things are getting pretty crazy, so run
这篇关于如何克隆Git中的所有远程分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
$ git克隆git://example.com/myproject
$ cd myproject
$ git branch
* master
-a
标志查看这些标记:
$ git分支-a
* master
遥控器/原点/ HEAD
遥控器/原点/主控器
遥控器/原点/ v1.0-稳定器
遥控器/原点/试验器
$ git checkout origin / experimental
$ git checkout experimental
分支实验设置用于跟踪从原点开始的远程分支实验。
切换到一个新的分支'实验'
它的真正含义是该分支从索引中获取并在本地为您创建。 前面的行实际上更具信息性,因为它告诉你该分支正在设置为跟踪远程分支,通常意味着origin / branch_name分支
$ git branch
* experimental
master
git remote
。
$ git remote add win32 git:// example。 com / users / joe / myproject-win32-port
$ git branch -a
* master
遥控器/原点/ HEAD
遥控器/原点/主控器
遥控器/原产地/ v1.0-stable
遥控器/原产地/实验型
遥控器/ win32 / master
遥控器/ win32 /新建窗口小部件
gitk
来看看发生了什么:
$ gitk --all&
master
and a development
branch, both pushed to GitHub. I've clone
d, pull
ed, and fetch
ed, but I remain unable to get anything other than the master
branch back.$ git clone git://example.com/myproject
$ cd myproject
$ git branch
* master
-a
flag:$ git branch -a
* master
remotes/origin/HEAD
remotes/origin/master
remotes/origin/v1.0-stable
remotes/origin/experimental
$ git checkout origin/experimental
$ git checkout experimental
Branch experimental set up to track remote branch experimental from origin.
Switched to a new branch 'experimental'
$ git branch
* experimental
master
git remote
.$ git remote add win32 git://example.com/users/joe/myproject-win32-port
$ git branch -a
* master
remotes/origin/HEAD
remotes/origin/master
remotes/origin/v1.0-stable
remotes/origin/experimental
remotes/win32/master
remotes/win32/new-widgets
gitk
to see what's going on:$ gitk --all &