git: cd from worktree to main checkout

♠ Previously . Problem statement : make my cdg shortcut jump from a linked Git worktree back to the main checkout when already at the worktree root. The shortcut originally stopped at the current checkout&rsquo;s root: alias cdg='cd "$(git root)"' I wanted two consecutive calls from a worktree subdirectory to behave like the following: worktree/subdirectory ↓ cdg worktree (at the root) ↓ cdg main…