Skip to content

ailecksandr/git-user-services

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git User Services GitHubCat

Small application with own service-based architecture.

Main purpose:

Changing git user in .gitconfig and SSH keys by round-robin.

Ruby version

1.9.3 and greater.

Usage:

  1. Separate users' configuration lines must be commented in .gitconfig:

    [user]
      # email = sample-user-1@gmail.com
      # name = Sample User 1
      email = sample-user-2@gmail.com
      name = Sample User 2
      # email = sample-user-3@gmail.com
      # name = Sample User 3
  2. (Optional) <.ssh> folder must have next tree structure:

    <.ssh>
      - id_rsa
      - id_rsa.pub
      <git-users>
        <sample-user-1@gmail.com>
          - id_rsa
          - id_rsa.pub
        <sample-user-2@gmail.com>
          - id_rsa
          - id_rsa.pub   
    
  3. Execute by

    ruby actions/change.rb
  4. After successful execution you will receive information about current user:

      ## Email was replaced to sample-user-3@gmail.com ##
      ## Name was replaced to Sample User 3 ##
      ## SSH keys were replaced ##
      ## <.gitconfig> was changed successfully! ##
  5. Current user will be changed to next in order:

    [user]
      # email = sample-user-1@gmail.com
      # name = Sample User 1
      # email = sample-user-2@gmail.com
      # name = Sample User 2
      email = sample-user-3@gmail.com
      name = Sample User 3

Also you can execute code in silent mode - just pass silent: true to Change::Process service.

Script-usage (preferred):

Simplified version of application is placed in <script> folder.

  1. Move to <script> folder:

    cd script
  2. Run shell script using

    ./guser.sh

Also you can execute code in silent mode - just pass true on shell script execution.

./guser.sh true

How to make script fast accessible everywhere in the system

  1. Copy script to closer to home folder

    mkdir -p ~/.ssh-swap && \
    cp script/guser.rb ~/.ssh-swap/
  2. Add alias to your console shell

    # For OhMyZsh users
    echo '\nalias guser="ruby ~/.ssh-swap/guser.rb"' >> ~/.zshrc && \
    source ~/.zshrc
    
    # For Bash users
    echo '\nalias guser="ruby ~/.ssh-swap/guser.rb"' >> ~/.bashrc && \
    source ~/.bashrc
  3. Execute the next command to swap git user

    guser

About

Playing with services

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published