Switch to main branch, clean up merged branches, and handle dependencies - all in one command
- 🔄 Auto-detects and switches to main/master branch
- 🧹 Cleans up fully merged branches
- 🚦 Handles dirty working directory gracefully
- 📦 Auto-updates dependencies if lockfile changed
- 🎯 Supports yarn, pnpm, and npm
- ⚡️ Fast and lightweight
npm install -g git-main
Or use it directly with npx:
npx git-main
Simply run git-main
in any git repository. The tool will:
- Switch to your main branch (auto-detects main/master)
- Clean up your working directory if needed
- Pull latest changes
- Remove fully merged branches
- Update dependencies if lockfile changed (supports yarn, pnpm, and npm)
The tool automatically detects your package manager based on lockfiles:
-
yarn.lock
→ usesyarn --immutable
-
pnpm-lock.yaml
→ usespnpm install --frozen-lockfile
-
package-lock.json
→ usesnpm ci
$ git-main
ℹ Using main branch: main
→ Fetching latest changes...
→ Pulling latest changes...
→ Cleaning up merged branches...
ℹ Deleting branch feature/123 (Branch is fully merged)
ℹ Deleting branch fix/456 (Branch content matches current main)
→ Installing dependencies with pnpm...
✓ All done! 🎉
MIT © Jan Nicklas