This Rust Git Wrapper is a custom command-line tool designed to intelligently select the appropriate SSH key for different Git repositories. It's particularly useful for managing multiple Git accounts (like personal and work accounts) on the same machine.
- Dynamically selects the correct SSH key based on the current working directory.
- Easy configuration via a YAML file.
- Transparent replacement of the standard Git command.
To use this Git wrapper, follow these steps:
- Rust and Cargo (the Rust package manager) must be installed on your machine. If you don't have them installed, you can get them from the Rust website.
- Ensure you have SSH keys set up for your different Git accounts.
-
Clone the Repository:
- Clone this repository to your local machine using:
git clone <repository-url>
- Clone this repository to your local machine using:
-
Build the Project:
- Navigate to the project directory and build the project with Cargo:
cd git_wrapper cargo build --release
- Navigate to the project directory and build the project with Cargo:
-
Configuration File:
- Create a
.git_ssh_ids
file in your home directory. This file should map your directories to their respective SSH keys. For example:default: ~/.ssh/default_id_rsa.pub directories: - path: ~/code/work key: ~/.ssh/work_id_rsa.pub - path: ~/code/personal key: ~/.ssh/personal_id_rsa.pub
- Create a
-
Replace the Default Git Command:
- Create an alias in your shell configuration (like
.bashrc
or.zshrc
):alias git="path/to/git_wrapper/target/release/git_wrapper"
- Create an alias in your shell configuration (like
Once installed, you can use the git
command as you normally would. The wrapper will automatically select the correct SSH key based on your current directory.
Contributions to this project are welcome! Feel free to fork the repository, make your changes, and submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.