• KissYagni@programming.dev
    link
    fedilink
    arrow-up
    3
    ·
    6 days ago

    I never really understood the advantage of worktree over having just several clone of the repos on different folders.

    Can someone explain me ? I should have missed smth.

    • Kissaki@programming.dev
      link
      fedilink
      English
      arrow-up
      4
      ·
      edit-2
      5 days ago

      Worktrees share the data stored in the .git folder. This saves storage (particularly on larger repos, and if you don’t fetch/clone only partial history), and could allow some other workflows or safeguards (backing up just one instead of multiple, centralized local state instead of spread across different workspaces). It also means it could share repo-local git settings - like remotes, local not checked-in ignores, etc. (I assume).

      • nous@programming.dev
        link
        fedilink
        English
        arrow-up
        4
        arrow-down
        1
        ·
        5 days ago

        It also lets you checkout, cherry-pick, rebase or merge work on other branches without needing to sync between the local clones.