Skip to content

Instantly share code, notes, and snippets.

@ff6347
Last active April 13, 2023 19:34

Revisions

  1. ff6347 revised this gist Oct 29, 2020. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions clone_remote_branch.md
    Original file line number Diff line number Diff line change
    @@ -10,14 +10,14 @@ First, clone a remote git repository and cd into it:
    Next, look at the local branches in your repository:

    $ git branch
    * master
    * main

    But there are other branches hiding in your repository! You can see these using the `-a` flag:

    $ git branch -a
    * master
    * main
    origin/HEAD
    origin/master
    origin/main
    origin/v1.0-stable
    origin/experimental

    @@ -36,19 +36,19 @@ But if you want to work on that branch, you'll need to create a local tracking b
    Now, if you look at your local branches, this is what you'll see:

    $ git branch
    master
    main
    * experimental

    You can actually track more than one remote repository using `git remote`.

    $ git remote add win32 git://example.com/users/joe/myproject-win32-port
    $ git branch -a
    * master
    * main
    origin/HEAD
    origin/master
    origin/main
    origin/v1.0-stable
    origin/experimental
    win32/master
    win32/main
    win32/new-widgets

    At this point, things are getting pretty crazy, so run `gitk` to see what's going on:
  2. fabiantheblind revised this gist Feb 7, 2013. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions clone_remote_branch.md
    Original file line number Diff line number Diff line change
    @@ -21,6 +21,10 @@ But there are other branches hiding in your repository! You can see these using
    origin/v1.0-stable
    origin/experimental

    If you already have a existing repository but there is a new branch that is yet listed do a:

    git fetch

    If you just want to take a quick peek at an upstream branch, you can check it out directly:

    $ git checkout origin/experimental
  3. @fabiantheblind fabiantheblind created this gist Nov 6, 2012.
    52 changes: 52 additions & 0 deletions clone_remote_branch.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    This is taken from here.
    http://stackoverflow.com/questions/67699/how-do-i-clone-all-remote-branches-with-git/72156#72156
    Want this as a gist because I always come back to this posting.

    First, clone a remote git repository and cd into it:

    $ git clone git://example.com/myproject
    $ cd myproject

    Next, look at the local branches in your repository:

    $ git branch
    * master

    But there are other branches hiding in your repository! You can see these using the `-a` flag:

    $ git branch -a
    * master
    origin/HEAD
    origin/master
    origin/v1.0-stable
    origin/experimental

    If you just want to take a quick peek at an upstream branch, you can check it out directly:

    $ git checkout origin/experimental

    But if you want to work on that branch, you'll need to create a local tracking branch:

    $ git checkout -b experimental origin/experimental

    Now, if you look at your local branches, this is what you'll see:

    $ git branch
    master
    * experimental

    You can actually track more than one remote repository using `git remote`.

    $ git remote add win32 git://example.com/users/joe/myproject-win32-port
    $ git branch -a
    * master
    origin/HEAD
    origin/master
    origin/v1.0-stable
    origin/experimental
    win32/master
    win32/new-widgets

    At this point, things are getting pretty crazy, so run `gitk` to see what's going on:

    $ gitk --all &