[Step 14] Multiple Workplace - Yellow-Team-Millerslab/GitPlayground GitHub Wiki

A git repository can support multiple working trees, allowing you to check out more than one branch at a time. ref

Use case: Need to do a hotfix on another branch, but you don't want to use stash.

This is not supported in VS2017 or SourceTree, so only can do this in command.

  1. Open Git bash and move to GitPlayGround folder

    enter this command

    git worktree add --checkout ../GitPlayGorund-master master

    It will create a folder called GitPlayGorund-master and checkout master branch

  2. Add this folder to SourceTree like Step 2

  3. Back to the original folder GitPlayGround, and make some changes and commit. In SourceTree, you can see the commit in both places.

Related Commands:

  • git worktree list
  • git worktree add -b [path] [branch name]