# Apple Browsers: Git worktrees A Git worktree is another checkout of the same repository. It lets you keep `main` and feature branches in separate folders, work on them independently, and share one Git history instead of cloning the repo again. In this setup, `apple-browsers.git/.git` stores that shared history; `main/` and feature folders are the worktrees. ## First-time setup ```sh mkdir -p ~/DuckDuckGo/apple-browsers.git git clone --bare https://github.com/duckduckgo/apple-browsers.git ~/DuckDuckGo/apple-browsers.git/.git cd ~/DuckDuckGo/apple-browsers.git git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*' git fetch origin git worktree add main main ``` ## Work on a branch From `~/DuckDuckGo/apple-browsers.git`: ```sh git fetch origin git worktree add -b yourname/my-feature my-feature origin/main cd my-feature git submodule update --init --recursive open DuckDuckGo.xcworkspace ``` The `git worktree add -b` command creates `my-feature/` on a new branch based on `origin/main`. Edit, build, commit, and push inside that folder. For an existing local branch, use `git worktree add `; for a remote branch, use `git worktree add --track -b origin/` if you have not created it locally. Use `git worktree list` to find checkouts. After checking that a checkout has no work to keep, run `git worktree remove ` from the container directory. The branch remains available.