How to clone all remote branches with Git

By | July 9, 2014

Question: I have a master and a development branch, both pushed to remote git repository. How to clone all remote branches with Git

Answer:

  1. clone the remote git repository: git clone git://example.edu/project_name
  2. list all hiden local branches: git branch -a

    $ git branch -a  
    * master  
      remotes/origin/HEAD -> origin/master  
      remotes/origin/master  
      remotes/origin/another-branch
  3. create a local tracking branch: git checkout -b another-branch remotes/origin/another-branch

  4. list local branches: git branch, and you will see the local branches

$ git branch  
    * master  
      another-branch

Leave a Reply

Your email address will not be published. Required fields are marked *