Cloning Multiple Branches in GitHub for Windows
Asked Answered
S

1

13

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.

Slr answered 12/6, 2012 at 15:57 Comment(7)
What do you mean by UI? is it Github's GUI you are talking about?Lumber
@uDaY: I'm talking about the new GitHub for Windows app.Slr
I also need this exact functionality - I hope it is added soon.Dryclean
It seems weird to me that this isn't one of the primary user stories that GitHub for Windows would support. What am I missing?Rodent
@andrew: Most people are probably expected to switch branches within a single clone.Slr
@SLaks: well that's fine until you want to work on multiple branches in parallel. The term Git us for this is 'context switching'. github for windows doesn't support it.Rodent
It would be interesting to see if GitHub for Windows will support the new git checkout --to=<path> command which will come with Git 2.5+ (Q2 2015): that would support multiple branch checkout (in different working trees). See https://mcmap.net/q/11286/-how-can-i-have-multiple-working-directories-with-git.Opportunist
M
9

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.
Musso answered 14/6, 2012 at 3:47 Comment(4)
That's what I'm doing right now. Note that you don't need to"stop tracking this repo", and that the repo tooltip is very useful.Slr
I've updated my answer and removed the "stop tracking this repo" part.Musso
This works really well, thanks! If any future readers need help cloning multiple branches of a single project, I used this: https://mcmap.net/q/36094/-how-do-i-clone-a-specific-git-branch-duplicateDryclean
I used the same way to have two branches in two respective folders so that I can compare two branches. I use github for window. And recently I find a strange thing: I have 3 projects. For 2 projects, the Github for Window can show two folders for each project simultaneously, which is very convenient for me. But the 3rd project, it can show one, either for the first branch or the second branch. But how come they follow different rules?Sexual

© 2022 - 2024 — McMap. All rights reserved.