From d57ea4ec27196d00eded3c57fb1bc6da470f4c8b Mon Sep 17 00:00:00 2001 From: Alexey Martemyanov Date: Fri, 16 Oct 2026 14:01:58 +0600 Subject: [PATCH] [2026-10-16] eagle: work/apple-browsers-worktree-workflow.md --- work/apple-browsers-worktree-workflow.md | 25 +++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/work/apple-browsers-worktree-workflow.md b/work/apple-browsers-worktree-workflow.md index 5a6ec95b..8e5be24f 100755 --- a/work/apple-browsers-worktree-workflow.md +++ b/work/apple-browsers-worktree-workflow.md @@ -1,6 +1,10 @@ # 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. +This instruction describes how to keep one shared Git database at e.g. `~/DuckDuckGo/apple-browsers.git/.git` and put independent checkouts beside it inside `apple-browsers.git/`. + +The container directory has no checked-out source of its own. + +Related: [Quickly add/remove/switch between worktrees](https://app.asana.com/1/137249556945/message/1210697449367306) ## First-time setup @@ -15,6 +19,20 @@ git worktree add main main ## Work on a branch +```sh +git fetch origin +git worktree add local-folder-name author/branch-name +cd local-folder-name +git submodule update --init --recursive +open DuckDuckGo.xcworkspace +``` + +- Edit, build, commit, and push **inside** `**local-folder-name/**` as with any clone. +- Each worktree has its own working files and branch; they share the same Git history. +- for a remote branch, use `git worktree add --track -b origin/` if you have not created it locally. +- 🔍 Use `git worktree list | grep branch-name-part` to find checkouts. +## New branch creation + From `~/DuckDuckGo/apple-browsers.git`: ```sh @@ -25,6 +43,7 @@ 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. +## Removing worktree -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. +- After you finish working on your feature, run `git worktree remove ` from the container directory. +- If you need to remove a worktree with changes you don‘t need anymore, run `git worktree remove -f `