1

Can you have two separate Git branches checked out on two different Windows desktops (same computer, just different desktops)?

user167698
  • 1,833
  • 6
  • 20
  • 25

1 Answers1

0

It’s a bit like a room with some windows. Observers can see the same room through different windows. When an observer throws a stone into the room, others can see the stone too.

I’m sure you know that two files with the same name can’t exist in the same directory. Besides, a ref like HEAD is not allowed to point to two or more refs or commits at the same time. So we can’t check out two branches at the same time in the same working tree. The foo.txt of master says “Hello World” and the foo.txt of release says “Hallo Welt”. You can visualize what problems we would face if we could checkout them both.

By “access”, if you mean read-only, then we don’t need working tree at all. Commands like git log, git rev-parse, git cat-file access the objects in git’s database. Of course it’s much more convenient to read real and familiar files like foo.txt than plain blobs like .git/objects/55/7db03de997c86a4a028e1ebd3a1ceb225be238. The command “git worktree” can check out branches into different working trees so we don’t have to make several clones. It’s helpful when the repo is very large. If the git version is too old to support “git worktree”, we can make some shallow clones or clone from the exisiting local repo, small and fast.

Hernando Abella
  • 286
  • 2
  • 13