Bookmark
Git - git-worktree Documentation
https://git-scm.com/docs/git-worktree, posted 2022 by peter in development documentation howto reference versioncontrol
In its simplest form,
git worktree add <path>automatically creates a new branch whose name is the final component of<path>, which is convenient if you plan to work on a new topic. For instance,git worktree add ../hotfixcreates new branchhotfixand checks it out at path../hotfix. To instead work on an existing branch in a new worktree, usegit worktree add <path> <branch>. On the other hand, if you just plan to make some experimental changes or do testing without disturbing existing development, it is often convenient to create a throwaway worktree not associated with any branch. For instance,git worktree add -d <path>creates a new worktree with a detachedHEADat the same commit as the current branch.If a working tree is deleted without using
git worktree remove, then its associated administrative files, which reside in the repository (see "DETAILS" below), will eventually be removed automatically (seegc.worktreePruneExpirein git-config[1]), or you can rungit worktree prunein the main or any linked worktree to clean up any stale administrative files.