10

I want to checkout multiple branches of the same git repostiory on the same Computer (Linux and Windows). However as the repository might be huge, I would prefer to have the repository once and only multiple working directories.

Is this possible? How so?

Zoe stands with Ukraine
  • 25,310
  • 18
  • 114
  • 149
Steffen Heil
  • 4,116
  • 3
  • 30
  • 35

1 Answers1

14

It is possible since Git 2.5 and its git worktree command.

It replaces an older script contrib/workdir/git-new-workdir, with a more robust mechanism where those "linked" working trees are actually recorded in the main repo new $GIT_DIR/worktrees folder (so that work on any OS, including Windows).

Once you have cloned a repo (in a folder like /path/to/myrepo), you can add worktrees for different branches in different independent paths (/path/to/br1, /path/to/br2), while having those working trees linked to the main repo history (no need to use a --git-dir option anymore)

See "Multiple working directories with Git?"

Community
  • 1
  • 1
VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755