The most basic operation is switching to an existing branch by name:
gitsw maingitsw feature-authgitsw bugfix/login-error```textIf the branch doesn't exist, you'll get an error:```bash$ gitsw nonexistenterror: Branch 'nonexistent' not found. Use -c to create it.
From src/main.rs:357-363, gitsw checks if the branch exists before attempting to switch.
gitsw first checks if the branch already exists (src/main.rs:357)
2
Handle uncommitted changes
If you have changes, you’ll be prompted to stash or discard them
3
Create the branch
The new branch is created from your current HEAD (src/main.rs:433-440)
4
Switch to it
gitsw performs the checkout operation
// From src/main.rs:433-440if !branch_exists && create { println!( "{} Creating branch '{}'...", "info:".blue().bold(), target_branch.green() ); repo.create_branch(target_branch)?;}```bash## Pull After SwitchSwitch to a branch and immediately pull the latest changes:```bashgitsw main -pgitsw develop --pull
This is useful when:
Updating your main/develop branch before creating a new feature branch
Syncing with remote changes after switching to a shared branch
By default, gitsw prompts you to stash uncommitted changes. Skip this with:
gitsw main --no-stash```bash<Warning> Using `--no-stash` may cause the switch to fail if you have uncommitted changes that conflict with the target branch.</Warning>## Quick Reference| Command | Description ||---------|-------------|| `gitsw branch` | Switch to existing branch || `gitsw -c branch` | Create and switch to new branch || `gitsw branch -p` | Switch and pull latest changes || `gitsw branch --no-stash` | Switch without stashing changes || `gitsw -c branch -p` | Create, switch, and pull |