| Crates.io | gitsw |
| lib.rs | gitsw |
| version | 0.1.0 |
| created_at | 2026-01-23 12:27:25.504117+00 |
| updated_at | 2026-01-23 12:27:25.504117+00 |
| description | A smart Git branch switcher with automatic stash management and dependency installation |
| homepage | https://github.com/yigiterdev/gitsw |
| repository | https://github.com/yigiterdev/gitsw |
| max_upload_size | |
| id | 2064333 |
| size | 90,978 |
A smart Git branch switcher with automatic stash management and dependency installation.
curl -fsSL https://raw.githubusercontent.com/yigiterdev/gitsw/main/install.sh | sh
cargo install gitsw
cargo install --git https://github.com/yigiterdev/gitsw
git clone https://github.com/yigiterdev/gitsw.git
cd gitsw
cargo install --path .
Download the latest release for your platform from Releases.
| Platform | Download |
|---|---|
| macOS (Apple Silicon) | gitsw-aarch64-apple-darwin.tar.gz |
| macOS (Intel) | gitsw-x86_64-apple-darwin.tar.gz |
| Linux (x64) | gitsw-x86_64-unknown-linux-gnu.tar.gz |
| Windows (x64) | gitsw-x86_64-pc-windows-msvc.zip |
Just run gitsw without arguments to get an interactive branch picker:
gitsw
Use arrow keys to navigate, type to filter, Enter to select.
gitsw main # Switch to main branch
gitsw feature-auth # Switch to feature-auth branch
If you have uncommitted changes, you'll be prompted to stash, discard, or abort.
gitsw -c new-feature # Create and switch to new-feature
gitsw main -p # Switch to main and pull latest
gitsw -p feature # Switch to feature and pull
gitsw -t origin/feature-api # Fetch, create local branch, and track remote
gitsw -s
Output:
Branch: feature-auth
Changes: 3 modified, 1 untracked
Stash: present
Package manager: npm
Tracking: origin/feature-auth
gitsw -r
Output:
Recent branches:
* [1] feature-auth (current)
[2] main (2 hours ago)
[3] develop [stash] (yesterday)
[4] feature-api (3 days ago)
gitsw -l
Shows all branches that have gitsw-managed stashes.
gitsw -d old-feature # Delete branch (cleans up associated stash)
Usage: gitsw [OPTIONS] [BRANCH]
Arguments:
[BRANCH] Target branch to switch to (interactive picker if omitted)
Options:
-l, --list List branches with stashes
-r, --recent Show recent branches
-s, --status Show current status (branch, stash, changes)
-d, --delete <BRANCH> Delete a branch (with stash cleanup)
-t, --track <REMOTE/BRANCH> Track and switch to a remote branch
--no-stash Skip automatic stash behavior
--no-install Skip automatic package install
-c, --create Create branch if it doesn't exist
-p, --pull Pull latest changes after switching
-h, --help Print help
-V, --version Print version
gitsw automatically detects and handles lock file changes for:
| Package Manager | Lock File |
|---|---|
| npm | package-lock.json |
| yarn | yarn.lock |
| pnpm | pnpm-lock.yaml |
When switching branches, if the lock file has changed, you'll be prompted to run the appropriate install command.
State is stored in .git/git-switch.json within your repository.
# Daily workflow
gitsw # Pick branch interactively
gitsw main -p # Update main branch
gitsw -c fix/bug-123 # Start new bugfix branch
gitsw -r # See recent branches
gitsw -t origin/release # Track release branch from remote
# Skip prompts
gitsw main --no-stash # Switch without stashing (may fail with conflicts)
gitsw feature --no-install # Switch without install prompt
MIT License - see LICENSE for details.
Contributions are welcome! Please feel free to submit a Pull Request.
# Clone the repo
git clone https://github.com/yigiterdev/gitsw.git
cd gitsw
# Install pre-commit hooks
./scripts/setup-hooks.sh
# Build and test
cargo build
cargo test
The pre-commit hook will automatically run cargo fmt --check and cargo clippy before each commit.