Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloning Multiple Branches in GitHub for Windows

I sometimes need to have two different branches of a GitHub repo on my local disk at the same time. (especially when dealing with gh-pages)

I usually do this by making multiple clones of the repo in different folder, with clone using a different branch.

Is it possible to do this in the GitHub for Windows UI? (as opposed to switching a single local clone from one branch to another)
It looks like the only way to switch between local clones is to drag the new clone into the UI every time.

like image 909
SLaks Avatar asked Jun 12 '12 15:06

SLaks


People also ask

How do I clone a git repository with all branches?

The idea is to use the git-clone to clone the repository. This will automatically fetch all the branches and tags in the cloned repository. To check out the specific branch, you can use the git-checkout command to create a local tracking branch.

Does git clone get all remote branches?

git clone downloads all remote branches but still considers them "remote", even though the files are located in your new repository. There's one exception to this, which is that the cloning process creates a local branch called "master" from the remote branch called "master".


1 Answers

I don't think it is possible to do what you want to do with the current version (1.0.9.2) but here is what I do to work on two branches.

  1. Clone the two branches from the Git Shell

    git clone https://your-project/master/ master

    git clone https://your-project/gh-pages/ gh-pages

  2. In Git for Windows, drag & drop the folder you want to work on.

  3. To switch branch, drag & drop the folder for the other branch.
like image 86
Sylvain Avatar answered Oct 06 '22 16:10

Sylvain