Overview
Behavior flags allow you to control gitsw’s automatic features like stash management and dependency installation. These flags are particularly useful in automation scripts or when you want to bypass interactive prompts.—no-stash
Disables automatic stash management when switching branches.Default Behavior
By default, when you switch branches with uncommitted changes, gitsw:- Detects uncommitted changes in your working directory
- Prompts you to choose: stash changes, discard them, or abort
- If you choose to stash, creates a branch-specific stash with the message format
git-switch: <branch-name> - Stores the stash reference in
.git/git-switch.jsonfor later restoration
With —no-stash
When you use the--no-stash flag:
Source Reference
Defined insrc/main.rs:44-45:
—no-install
Disables automatic package installation prompts when lock files change.Default Behavior
By default, when you switch branches, gitsw:- Detects supported lock files (package-lock.json, yarn.lock, pnpm-lock.yaml)
- Compares the current lock file hash with the stored hash for the target branch
- If changed, prompts you to run the appropriate package manager install command
- Stores the lock file hash after installation for future comparisons
With —no-install
When you use the--no-install flag:
handle_package_install function call in src/main.rs:508-510:
With -c/—create
When you use the create flag:Source Reference
Defined insrc/main.rs:51-53:
-p, —pull
Pulls the latest changes from the remote repository after switching branches.Default Behavior
By default, gitsw only switches branches without fetching or pulling:- Switches to the target branch first
- Attempts to pull changes from the tracking remote
- Displays success or failure message
- Continues with stash restoration and package install checks
Behavior Details
- If the branch has no remote tracking branch, pull will fail with a message
- Pull happens after branch switch and stash restoration
- Does not abort the switch if pull fails (only displays warning)
- Works when you’re already on the target branch
Use Cases
1. Updating main/develop branchesSource Reference
Defined insrc/main.rs:55-57: