• Stars
    star
    111
  • Rank 307,906 (Top 7 %)
  • Language
    Shell
  • License
    Do What The F*ck ...
  • Created over 11 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Manage your identity in Git

git-identity

You often use Git in different contexts, like at work and for open-source projects. You may then want to use different user names/email pairs to identify yourself.

This is not an important part of your work, and setting this up should be really fast. That's where git-identity comes in: setting up your identity information only takes one command with it.

Note: Identities are stored in the global git config. Using an identity copies the setting in the local repo git configuration. If you are changing the global config for one identity does NOT propagate the changes to the local repos. You will have use git identity --update in the repo folder to update the identity.

Installing

Simply link or copy the git-identity in a directory that's in your PATH, Git will pick it up and make it available as git identity.

$ ln -s git-identity ~/bin/git-identity

Under Windows, go to System > Advanced System Parameters > Environment Variable. Find the "Path" entry under system variables and add the path to where you downloaded git-identity.

Then you may setup a default identity with the following command (see Usage for more information):

$ git identity --define default Me [email protected]

To get bash completion, just source the git-identity.bash-completion file in your initialization scripts, such as .bashrc.

To get zsh completion, move the git-identity.zsh-completion file to a location present in your $FPATH, renaming the file to _git-identity.

You can also use basher to install git-identity:

$ basher install madx/git-identity

Usage

Add an identity:

$ git identity --define <identity name> <user name> <user email> [<ssh-file>] [<gpgkeyid>]

Add a GPG key to the identity (see GPG specific information below)

$ git identity --define-gpg <identity name> <gpgkeyid>
Added GPG key DA221397A6FF5EZZ to [default] user <[email protected]> (GPG key: DA221397A6FF5EZZ)

Add a SSH key to the identity

$ git identity --define-ssh <identity name> <ssh-file>
Added SSH key id_rsa_anotheraccount to [default] user <[email protected]> (SSH key: id_rsa_anotheraccount)

Print the current identity:

$ git identity
Current identity: [default] user <[email protected]>

Change identity:

$ git identity user2
Using identity: [default2] user2 <[email protected]>

Update identity:

$ git identity --update
Using identity: [user] First Last <[email protected]> (SSH key: id_rsa_user_new_key)
These are the changes:
1,2c1,2
<   core.sshcommand ssh  -i ~/.ssh/id_rsa_user
<   user.email [email protected]
---
>   core.sshcommand ssh  -i ~/.ssh/id_rsa_user_new_key
>   user.email [email protected]

List all identities:

$ git identity --list
Available identities:
[default] user <[email protected]>
[default2] user2 <[email protected]>

Listing raw identities:

$ git identity --list-raw
default
default2

Deleting an identity:

$ git identity --remove <identity name>

Printing the raw identity (for use in scripts)

$ git identity --print
$ git identity --print <identity name>

Priniting the local settings

$ git identity --get-settings
core.sshcommand ssh -i ~/.ssh/id_rsa_user
user.email [email protected]
user.identity user
user.name First Last

Retriving GIT_SSH_COMMAND or running command with that in the environment:

$ git identity -c my_other_identity
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_myotheridentity"

$ git identity -c my_other_identity git clone [email protected]:me/myrepo.git
Cloning into 'myrepo'...

Setting up GPG

More information about how to use GPG with git-identity may be found in GPG_SETUP.md

Setting up SSH

If you have a valid SSH key associate to the agent you do not have to do anything beside git identity --define-ssh <identity name> <ssh-file>.

This sets core.sshCommand="ssh -i ~/ssh/ssh-file" in the local git config when using that identity

Creating a new identity

    ssh-keygen -t rsa -b 4096 -C "yourname@yourdomain" -f ~/.ssh/id_rsa_anotheraccount
ssh-add id_rsa_anotheraccount

Debugging a ssh connection problem

git identity --define-ssh <identity name> <ssh-file> <verbosity>

With verbosity=1 it will use ssh -v. With verbosity=2 it will use ssh -vvv.

More Repositories

1

roy

make your objects REST-friendly
Ruby
138
star
2

moreutils

my clone of the UNIX moreutils
C
105
star
3

haze

A minimalistic blogging engine, the successor of Honk
Ruby
18
star
4

elfi

An elegant state container for your JavaScript applications
JavaScript
17
star
5

sharedrop

Easily share files using your own server
Shell
11
star
6

honk

my blogging engine - sinatra + yaml
Ruby
9
star
7

obsidian-dv-paginate

A Dataview view script to render a paginated collection
JavaScript
8
star
8

veil

Make-based static website builder using Jade and Stylus
CSS
6
star
9

windsock

Generate React components from Tailwind classes
JavaScript
6
star
10

shumblr

A Tumblr client written in Shoes
Ruby
5
star
11

targetz

URL shortening/bookmarking using Sinatra & CouchDB
Ruby
5
star
12

ouiche

a small wiki-like system in Sinatra w/ text files
Ruby
4
star
13

gifcast

Linux GIF screencasting made easy:
Shell
4
star
14

prezto

A fast and simple JavaScript slideshow system
HTML
4
star
15

mdwn.in

[DOWN & DEPRECATED] A Markdown rendering service.
Ruby
4
star
16

propane

My setup scripts
Lua
4
star
17

obsidian-budget-tracker

My Obsidian budget tracker view
JavaScript
4
star
18

brume

a lightweight static website manager on top of git
Shell
3
star
19

solylace

A Shoes text editor
Ruby
3
star
20

shrrred

A Ruby regular expression tester in Shoes, greatly inspired from Rubular
Ruby
3
star
21

shitstorm-old

A minimalist bug tracker written in Ruby with Sinatra and Sequel
Ruby
3
star
22

termki

A text-based and REST-oriented Wiki with Sinatra
Ruby
3
star
23

jumpr

like autojump and friends, in ruby + yaml
Shell
3
star
24

computational_geometry

Source code for my computational geometry course
C
3
star
25

merb-todolist

A small todo list written with Merb
Ruby
3
star
26

todo

My command-line todolist manager
3
star
27

jspell

A Java spellchecker (Uni project)
Java
2
star
28

gp2sass

A little script to convert color palettes to Sass constant sets
2
star
29

metash

A Hash that allows method calls to get elements
Ruby
2
star
30

140.ru

A Rack-compliant Ruby framework that fits in a tweet
Ruby
2
star
31

patches

Various patches I made
2
star
32

listr

A directory browser in PHP
2
star
33

xup

A lightweight and modular markup language in pure Ruby
Ruby
2
star
34

ruby-lugdunum

Ruby Conf Lyon 2011
JavaScript
2
star
35

ubiquity-commands

Some homemade Ubiquity commands
JavaScript
2
star
36

rzen

A Zenity frontend in Ruby
Ruby
2
star
37

dicelib

A dice library in Ruby
Ruby
2
star
38

recettes

Mes recettes de cuisine
2
star
39

vim-plugins

My personnal vim plugins and helpers
Vim Script
2
star
40

madx.github.com

My GitHub Page
2
star
41

mtest

A micro test "framework"
Ruby
2
star
42

bm

Quickly jump to bookmarked places in your filesystem.
Shell
2
star
43

rwh

Study exercises from the Real World Haskell book
Haskell
1
star
44

calico

A lightweight markup language
Ruby
1
star
45

compilation_classes

my work for my compilation classes
C
1
star
46

trigger

Launch a command when files are modified
Shell
1
star
47

madx.me

The source and scripts for my personal website
CSS
1
star
48

therm

My terminal emulator (VTE-based)
Vala
1
star
49

wex

A wofi-based text expander and generic executor
Shell
1
star
50

kopay

My own Discord bot/assistant!
JavaScript
1
star
51

koleirs-toolbox

My custom Obsidian utilities
JavaScript
1
star