set-branch¶
Create and switch to a branch in all repositories.
Usage¶
Description¶
The set-branch command ensures all repositories in your workspace are on the same branch. It creates the branch if it doesn't exist in a repository, or switches to it if it does.
Arguments¶
| Argument | Description |
|---|---|
BRANCH_NAME |
The name of the branch to switch to |
Behavior¶
- Validates clean state - Checks that all repositories have no uncommitted changes
- Creates or switches - For each repository (root and sub-repos):
- If the branch exists, switches to it
- If the branch doesn't exist, creates it and switches to it
- Maintains consistency - Ensures all repos end up on the specified branch
Examples¶
Create and switch to a feature branch¶
Switch to an existing branch¶
Switch to a release branch¶
Requirements¶
- All repositories must have a clean working directory (no uncommitted changes)
- Git must be available in your PATH
Error Handling¶
If any repository has uncommitted changes, the command will fail with an error message indicating which repository is not clean. Commit or stash your changes before running set-branch.
# If you have uncommitted changes
git stash # or commit your changes
multi set-branch feature/new-branch
git stash pop # if you stashed
Notes¶
- This command operates on both the root repository (if it exists) and all sub-repositories
- Branch creation is done locally; use
multi git push -u origin BRANCH_NAMEto push to remote - The command is idempotent - running it when already on the branch is safe