Search code examples
gitgithubbranchgit-branchgit-remote

How do I add existing remote branch to my locally cloned repository?


I would like to add this branch to my local clone: https://github.com/dmitriz/mithril.js/tree/rewrite

For some unclear reason, it did not get cloned.

So I ended up with local directory without that branch. Is there any easy way to clone this branch too?


Solution

  • All you have to do is checking out to this branch.

    $ git checkout rewrite
    

    Git will switch to a new branch, tracking the remote one. Here is the message you should get

    Branch rewrite set up to track remote branch rewrite from origin.
    Switched to a new branch 'rewrite'