Danyjex Danyjex - 2 months ago 8
Git Question

Is it possible to show all local branches at the same time in Windows Explorer?

Let's say i have 2 remote branches, Master and Developer, and that my local repository is on the folder D:/Git_Project.

On git bash i go to the repository directory and select Master branch, i make a folder and a file inside it, commit changes, push it to remote master branch.
Now i switch to the developer branch, and if i now go to D:/Git_Project with windows explorer, i can't see the folders / files from the master branch.

Now, i know that git saves those changes under the .git folder, and loads / saves them whenever we switch branches. But is it possible to have it always show both branches, each with their own folder?
Basically having a "Master" and "Developer" folder under D:/Git_Project .

I know i could "cheat" and make it all in the same branch and create those folders myself, but i would lose the git branch features if i did so.

The reason i would want this is because sometimes when working on some file in the developer, or any other branch, i might want to check a particular file from another branch, and it's quite annoying to always have to switch branch just to open a file locally.

Thank you.

Answer

Instead of placing your repo directly under D:/Git_Project, you can clone it under

D:/Git_Project/master

Then, with git worktree (with Git 2.5+), you can checkout the develop branch of that same repo in

git worktree add ../develop develop
D:/Git_Project/develop

That way, you don't need to clone twice (even shared clones are not needed here)