1.7 KiB
Executable File
1.7 KiB
Executable File
Apple Browsers: Git 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
First-time setup
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
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 <branch> <folder> origin/<branch>if you have not created it locally. - 🔍 Use
git worktree list | grep branch-name-partto find checkouts.
New branch creation
From ~/DuckDuckGo/apple-browsers.git:
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
Removing worktree
- After you finish working on your feature, run
git worktree remove <folder>from the container directory. - If you need to remove a worktree with changes you don‘t need anymore, run
git worktree remove -f <folder>