Bounty short description
Is there a portable way to use a single repository w/ multiple checkouts? As an alternative to ha
A branch when checked out is only a pointer to a commit (within a graph of commit).
As such, Git cannot check out two commits of that graph at the same time.
Actually, see "Multiple working directories with Git?".
With Git 2.5+ (Q2 2015), you can have multiple working trees for one git repo, with git checkout --to=
.
That allows you to Check out a branch in a separate working directory at
. A new working directory is linked to the current repository.
That link is "portable" (ie works even on Windows) as it is recorded in the main repo $GIT_DIR/worktrees
directory.
Original answer (2011):
(Source: Scott Chason, ProGIT Book, http://progit.org/book/ch3-1.html, CC-BY-NC-SA)
If you need to work on two different branches at the same time, simply clone your repo and select (git checkout
) the other branch in that clone. You can use the name of the branch as the name of the root directory for that clone.
And you can create branches in any of those repos.
So the question is why can't Git have TWO pointers, one for each directory? –
As mentioned in "Popularity of Git/Mercurial/Bazaar vs. which to recommend", Git is at its core a content management. Each commit represents a full snapshot of the repo.
You cannot view two contents in the same container (working directory), even though you can keep reference of as many pointer (branches) as you want.
You only populate the working directory with one content.