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 expected branch. It creates the branch if it doesn't exist in a repository, or switches to it if it does. Repos configured with fixedBranch stay on their configured branch.
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 the root repository and each non-fixed sub-repo:
- 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, except repos with
fixedBranch
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
- Sub-repositories with
fixedBranchinmulti.jsonare checked out to that fixed branch instead - 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