Simple setup - big mess with master and gh-pages

Started a new repo in Github online. Agreed to have also a gh-pages branch for a website related to the repo.
Fetched the repo locally with Github Desktop (GD) and it shows correctly two branches (master and gh-pages) in ‘Current branch’ dropdown.
Somehow Github Desktop decided that I should have both branches in the same local folder. Which is a really bad idea, the two contents are completely different - one is a code library, the other is a website! In order to “accommodate” me GD is “stashing” the entire folder every time I switch between the two branches. What?
Yes, it gives me one or the other, but can’t have both at the same time. Kind of a hostage situation. Have to rely on GD to provide my files, can’t backup, can’t see/edit the two branches at the same time - a mess!

  1. Is there a way to instruct Github Desktop to save (and keep!) master and gh-pages branches in their own separate disk folders ?

  2. Secondary (less important) question: how could one fall in this trap ? What instruction did I miss, overlooked or did not follow?

(Environment is Github Desktop Version 2.6.3 on Windows 10 Pro.)

This is standard Git behavior. The working tree directory remains the same as you switch branches. Branches are primarily intended for variations of the same thing (e.g. developing a feature without affecting the main code until it’s ready), even though you can use them in other ways.

Git also supports worktrees: Separate working tree directories referring to the same local repository, from your description I’m pretty sure that’s what you want. On the command line you can use git worktree to set that up. Maybe you can find a similar option in Github Desktop, or someone else can say how to do that?

1 Like

Thank you, airtower-luna for the right direction! Worktree is indeed the solution, lot of demand and positive reviews. Unfortunately neither Github Desktop, nor SourceTree deem it worthy and both do not support it.

There is a workaround - just clone one branch in a different folder. Tried and was able to push gh-pages to origin successfully from the second folder. Github Desktop shows both repos with identical names in the repository list, but we can live with that