Git - Store branches in separate local directories

前端 未结 3 659
南方客
南方客 2020-12-07 21:00

I\'m rather new to git, and am trying to set up my repository the right way.

Basically my app is a platform of sorts, so implementations of this platform are based o

3条回答
  •  感动是毒
    2020-12-07 21:36

    You can do this using git worktree that was introduced in Git 2.5, circa July 2015.

    git clone -b master  master
    cd master
    
    # checking out implementation_1 in ../imp_1
    git worktree add ../imp_1 implementation_1
    
    # creating branch implementation_2 at master~2 as you check it out in ../imp2:
    git worktree add -b implementation_2 ../imp_2 master~2
    

    And voilà! You're done.

    With this setup, you'll have only one .git folder (in master/.git). Note that any branch can be checked out in a single worktree at a time.

提交回复
热议问题