To work on a second branch without disturbing your current Mac project checkout, create a Git worktree in a neighboring folder. Each worktree has its own files and checked-out branch, while sharing repository data with the main checkout. Create it from Terminal, open its folder in Finder or your editor, and remove it with Git when finished. Git’s worktree documentation
What a worktree changes
A worktree gives you another working directory connected to the same Git repository. That means you can keep, for example, your current main checkout open while a feature branch has a separate folder and files. Changes in one working directory do not overwrite the other’s checked-out files. Git shares repository data, but keeps worktree-specific state such as the index and HEAD separate. Git: git-worktree
Branches are shared across worktrees, and a local branch ordinarily cannot be checked out in two worktrees at once. Worktrees suit separate, concurrent tasks; they are not independent repository clones. Files ignored by Git, such as local configuration or build output, may need to be created separately in the new folder.
Create a feature worktree on macOS
Open Terminal and move into your existing project directory. Replace my-app with the directory name of your repository. The example assumes it lives in ~/Projects/my-app and creates the new checkout beside it.
cd ~/Projects/my-app
git status --short
git worktree add -b feature/search-ui ../my-app-search-ui
The status command lets you see whether the current checkout has pending changes before switching context. The add -b command creates a new local branch named feature/search-ui and checks it out in the neighboring my-app-search-ui directory. Git creates a branch from the current HEAD when no starting commit is specified. Choose a unique branch and a destination path that is not already in use. Git: worktree add
For an existing local branch that is not checked out in another worktree, use its name instead of -b and a new branch name:
git worktree add ../my-app-search-ui existing-branch
If the branch is already checked out elsewhere, Git refuses by default. Don’t force it just to bypass the safeguard; use a different branch or work in the checkout that already owns it. To create a worktree for a remote branch, fetch the remote first if needed and follow Git’s tracking-branch behavior; verify the branch name before adding it.
Open the new checkout in Finder and your editor
In Finder, navigate to the parent folder that contains both project directories, then open my-app-search-ui. You can use Finder’s Go to Folder command (Shift-Command-G) and enter the full path, such as ~/Projects/my-app-search-ui. Keep the directory name visible in Finder or your editor so you can distinguish it from the original checkout.
Apple also documents opening Terminal at a selected folder from Finder: show the Path Bar with View > Show Path Bar, Control-click the folder in the Path Bar, then choose Open in Terminal. To open another Terminal window or tab, use Command-N or Command-T. The selected folder’s location becomes the working directory for the Finder action. Apple: Open new Terminal windows and tabs on Mac
Open the new folder as a separate project in your editor using that editor’s documented open-folder control. Editor behavior varies; Git worktrees do not automatically create editor windows or configure your development environment. Dependency directories, ignored files, local environment files, and running services may require separate setup in each checkout.
Check which checkout you are using
From either project directory, run:
git worktree list
Git lists the main worktree and linked worktrees, including their paths and checked-out branches. Before committing or running commands that change files, confirm the current folder or run git status there. This simple check helps catch the common mistake of making edits in the original checkout while intending to work in the new one. Git: worktree list
Remove a worktree when the task is done
First commit or otherwise preserve any work you need. Then, from any worktree belonging to the repository, remove the linked checkout by path:
git worktree remove ../my-app-search-ui
git worktree list
Git normally refuses to remove a worktree that contains modified tracked files or untracked files. Review and preserve those files before removal; --force overrides Git’s protection and can discard work. The command removes the worktree directory, so don’t use it as a substitute for checking what is inside. Once removed, the branch remains available in the repository unless separately deleted. Git: worktree remove
If you deleted a worktree folder manually, Git may retain its administrative record. Use git worktree prune to clean up stale records; prefer git worktree remove for normal cleanup. If you move a linked checkout in Finder, Git may lose track of its location; use git worktree move where applicable or git worktree repair to reconnect it. Git: worktree prune, move, and repair
A practical Mac setup is one worktree folder per active task, with short, recognizable folder and branch names. Keep the main checkout for its current work, create a sibling checkout for a parallel task, and verify the path before editing. That gives each task its own project files without repeatedly switching the original checkout’s branch.
Sources
Open new Terminal windows and tabs on Mac — Apple Support