Skip to content

Variant is an attempt at automating the tedious process of switching git profiles on local.

Notifications You must be signed in to change notification settings

muse254/variant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Variant logo

This tool addresses the challenge of managing multiple Git profiles, such as work and personal, by offering a convenient and efficient means of switching between them.

It's important to note that the process is not atomic, if something fails in the middle of the process, you might end up with a broken configuration. I'm working on a way to make this process more robust.

Installation

variant assumes that you have already have git installed and configured. Also the ssh-add command is expected to be available in your PATH, this is what it does.

Installation with cargo

If you already have cargo installed in your system, use these steps.

 cargo install --git https://github.com/muse254/variant.git@main

Usage

It assumes a directory structure that looks like this for the git accounts to be managed, foo and bar:

├── ~/.ssh
│   ├── foo
│   │   ├── config
│   │   ├── id_rsa
│   │   ├── id_rsa.pub
│   ├── bar
│   │   ├── config
│   │   ├── id_rsa
│   │   ├── id_rsa.pub

It's important to note that the name of the folder and the name of the git profile match, in this case foo and bar. When switching profiles, variant will try to pig the git server to ensure that changes effectively took place.

When I create a new repository, I can specify which account to use:

cd my-awesome-project # We navigate to the project directory
variant var -n foo # We specify which account to use, assuming variant is in PATH

This changes the global git configuration to use the foo account. If you need to only configure an account for the current repository, you can use the --sacred flag:

cd my-awesome-project
variant var -n foo --sacred

This will tie the project to the specified profile and use local git configuration.

We can also query for information about the profile configured:

variant whoami -v

Other

The project is really a wrapper around git and the ssh commands, so it's not doing anything special. The selling point is ergonomics.

With aliasing magic, I can do this:

alias vf="variant var -n foo"
alias vb="variant var -n bar"
vf # Switch to foo
vb # Switch to bar

With some imagination, switching accounts becomes a breeze.

About

Variant is an attempt at automating the tedious process of switching git profiles on local.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages