Giter Club home page Giter Club logo

git-passport's Introduction

What is git-passport?

git-passport is a Git command and hook written in Python to manage multiple Git users / user identities.

Get it!

mkdir -p ~/.git/hooks/bin && cd $_
git clone git://github.com/frace/git-passport.git
chmod +x ./git-passport/git-passport.py

Installation

There are many ways to handle your hooks. What I do in order to work with multiple hooks is the following solution:

mkdir -p ~/.git/hooks/pre-commit.d && cd $_
ln -sf ~/.git/hooks/bin/git-passport/git-passport.py ./00-git-passport
mkdir -p ~/.git/templates/hooks && cd $_
touch pre-commit && chmod +x $_

Add the Git template directory path into your ~/.gitconfig and create an alias in order to be able to execute the script manually as a «native» git command by invoking git passport:

[alias]
    passport = !${HOME}/.git/hooks/bin/git-passport/git-passport.py

[init]
    templatedir = ~/.git/templates

In ~/.git/templates/hooks/pre-commit I put a little bash script which loads one hook after another:

#!/usr/bin/env bash

hooks_pre_commit="${HOME}/.git/hooks/pre-commit.d/"

for hook in ${hooks_pre_commit}*; do
    "$hook"
done

Afterwards each git init or git clone command will distribute the hook into a new repository. If you want to apply the hook to already exisiting repos then just run git init inside the repository in order to reinitialize it.

Configuration

On the first run git-passport.py generates a sample configuration file inside your home directory:

cd ~/.git/hooks/bin/git-passport
./git-passport.py
   No configuration file found in ~/.
   Generating a sample configuration file.

The configuration file ~/.gitpassport is rather self-explanatory:

[general]
enable_hook = True
sleep_duration = 0.5

[passport 0]
email = [email protected]
name = name_0
service = github.com

[passport 1]
email = [email protected]
name = name_1
service = gitlab.com

Adjust the existing sections and add as many passports as you like by following the section scheme.

Usage

If you setup the script as a hook only it will be invoked automatically during each git commit command. You can pass the following options if you use git-passport.py as a Git command, too:

git passport -h
   usage: git passport (--select | --delete | --active | --passports)

   manage multiple Git identities

   optional arguments:
     -h               show this help message and exit
     -s, --select     select a passport
     -d, --delete     delete the active passport in .git/config
     -a, --active     print the active passport in .git/config
     -p, --passports  print all passports in ~/.gitpassport

Bugs

You are welcome to report bugs at the project bugtracker at github.com.


Credits:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.