-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHelp.html
36 lines (36 loc) · 1.98 KB
/
Help.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<p>http://stackoverflow.com/questions/67699/clone-all-remote-branches-with-git</p>
<p>First, clone a remote Git repository and cd into it:</p>
<pre><code>$ git clone git://example.com/myproject
$ cd myproject</code></pre>
<p>Next, look at the local branches in your repository:</p>
<pre><code>$ git branch
* master</code></pre>
<p>But there are other branches hiding in your repository! You can see these using the -a flag:</p>
<pre><code>$ git branch -a
* master
remotes/origin/HEAD
remotes/origin/master
remotes/origin/v1.0-stable
remotes/origin/experimental</code></pre>
<p>If you just want to take a quick peek at an upstream branch, you can check it out directly:</p>
<pre><code>$ git checkout origin/experimental</code></pre>
<p>But if you want to work on that branch, you'll need to create a local tracking branch:</p>
<pre><code>$ git checkout -b experimental origin/experimental</code></pre>
<p>and you will see</p>
<p>Branch experimental set up to track remote branch experimental from origin. Switched to a new branch 'experimental' That last line throw some people "New branch" - huh? What it really means is a new local branch that gets the branch from the index and creates it 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</p>
<p>Now, if you look at your local branches, this is what you'll see:</p>
<pre><code>$ git branch
* experimental
master</code></pre>
<p>You can actually track more than one remote repository using git remote.</p>
<pre><code>$ 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</code></pre>
<p>At this point, things are getting pretty crazy, so run gitk to see what's going on:</p>
<pre><code>$ gitk --all &</code></pre>