Member-only story
Using multiple working trees in Git

Have you ever found yourself cloning a git repository a second time so that you could work on different things? Or have you ever had to stash all your changes, or make a quick commit, so you could shift your focus to solving a bug that was just reported from production?
Whether you have found yourself in such a situation or you haven’t (that time may come), it’s always nice to know what the tools you use are offering.
Git working trees
After initializing a local git repository, there is exactly one working tree. The one that was initialized by git init
or by cloning the repository. At any given time, there is exactly one branch checked out within a local repository. That branch can still be changed at will, forth, and back. But if you wanted to have two branches checked out at once, you could clone the repository a second time into another directory, thereby downloading everything again. But this feels a bit cumbersome and maybe a bit too much, doesn't it?
Adding another working tree
Luckily, git offers the feature of adding multiple (linked) working trees by not requiring another clone of a remote repository.
Within a local git repository, the following command adds a new working tree for an existing branch: