Blog

Git | Setup Workrtree

Question

What is the best way to setup git worktree?

Answer

  1. Create bare clone and put it to project/.git. This way git files will not be in a root of a project

    $ git clone --bare [email protected]:user/project.git project/.git
    
  2. Update .git/config. To make behave more normally and be fetchable.

     [core]
            repositoryformatversion = 0
            filemode = true
            bare = true
    +       logallrefupdates = true
            precomposeunicode = true
     [remote "origin"]
            url = [email protected]:imomaliev/til.git
    +       fetch = +refs/heads/*:refs/remotes/origin/*
    
  3. git fetch

Tags: