🔐 SSH Key Management for Git, Simplified.
gitsm
is a powerful Git wrapper that automatically configures different SSH keys for different repositories. No more editing ~/.ssh/config
, just clone and go.
- Do you use multiple GitHub or GitLab accounts?
- Do you need to use different SSH keys for different projects?
- Are you tired of editing
.git/config
or~/.ssh/config
by hand? - Do you want a cross-platform solution that "just works" on Windows, macOS, and Linux?
gitsm is the solution you need.
Demonstration: Repository cloning with interactive SSH key selection and automatic configuration.
- Auto-discovery: Automatic detection of SSH keys in your
~/.ssh
directory - Per-repository Configuration: Each repository can use a different SSH key
- Smart Cloning: Interactive SSH key selection during clone operations
- Repository Management: Commands to fix, convert, and manage repositories
- Key Management: List and validate SSH keys across your system
- Security: Built-in SSH key testing and validation
- State Management: Persistent configuration storage
- Branch Operations: Safe branch switching with state preservation
- Cross-platform: Full support for Windows, macOS, and Linux
npm install -g gitsm
Run gitsm clone
instead of git clone
.
gitsm clone [email protected]:username/repo.git
gitsm
will prompt you to select an SSH key from your ~/.ssh
directory. It then clones the repository and automatically configures it to use that key for all future Git operations (pull
, push
, fetch
, etc.).
Once cloned, you can use standard Git commands inside the repository.
cd repo
git pull
git push
See all repositories configured with gitsm
.
gitsm list repos
If you move your SSH keys or encounter a path error, gitsm fix
can repair the configuration.
gitsm fix /path/to/your/repo
Command | Description | Options | Example |
---|---|---|---|
clone |
Clone a repository with SSH key selection | --dir <directory> : Target directory |
gitsm clone [email protected]:user/repo.git |
switch |
Safely switch branches with stash handling | --force : Force switch with changes--no-pull : Skip pulling updates--create : Create new branch |
gitsm switch feature-branch |
convert |
Convert existing repo to use gitsm | [repoPath] : Path to repository(defaults to current directory) |
gitsm convert ~/projects/myrepo |
list keys |
Show available SSH keys | None | gitsm list keys |
list repos |
Show gitsm-managed repositories | None | gitsm list repos |
fix |
Repair SSH configuration | <repoPath> : Repository path |
gitsm fix ~/projects/myrepo |
upgrade |
Update gitsm to latest version | None | gitsm upgrade |
help |
Show command help | [command] : Show help for specific command |
gitsm help switch |
- Node.js: Version 16.x or higher.
- Git: Must be installed and available in your system's PATH.
- SSH Directory: Must have a
.ssh
directory in your home folder:- Unix/Linux/macOS:
~/.ssh
- Windows:
C:\Users\YourUsername\.ssh
- Unix/Linux/macOS:
- SSH Keys: SSH keys must be in the root of your
.ssh
directory (not in subdirectories)- Example:
~/.ssh/id_rsa
,~/.ssh/id_ed25519
- Public keys must have
.pub
extension:id_rsa.pub
,id_ed25519.pub
- Example:
This project is licensed under the MIT License.
Contributions are welcome! Please feel free to open an issue or submit a pull request. Whether it's a bug report, feature request, or documentation improvement, all contributions are appreciated.
Made with ❤️ for developers who juggle multiple SSH keys.