Create a feature branch in a new git worktree, as a sibling directory of the current project.
Rules
- Never use
git checkout -borgit switch -cin the main working directory. All feature branches must be created as worktrees usinggit worktree add. The main directory must always stay on the main branch. - Never generate a branch name — always take it from the user or the issue number.
Steps
- Take the branch name from the argument. If none provided, ask the user — never generate a name.
- Fetch the latest main:
- git fetch origin main
- Create the worktree:
- git worktree add../<branch-name> -b <branch-name> origin/main - This creates ../<branch-name>/ alongside the current project directory
- Confirm to the user:
- Show the branch name - Show the worktree path