Chapter 14Working with Trees and Modules in Git
In this book, you’ve primarily been working with single projects managed in a single repository where you worked on only one branch at a time. This works well for most projects, but there are times when you need to extend this model. Two such examples include working on multiple branches concurrently in a project, and including other repositories as subprojects or subdirectories.
WORKTREES
As I discuss in Chapter 8, one nice feature of Git is that you can use the same working directory for all of the branches you need to work with. However, as it turns out, this can also be a liability.
In the past, if you were making changes in one branch and needed to switch to a new branch, you had three choices: commit your changes to get to a clean working directory, stash your changes that were in progress, or create a separate clone of the repository in a different area and work on the other branch there.
Starting with version 2.5, Git formally introduced a more workable alternative: worktrees (working trees). The idea with worktrees is that you can have multiple, separate working directories, all connected to the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access