项目作者: DrVanScott

项目描述 :
Automatic setup of user identity (user.email / user.name) on git clone
高级语言: Shell
项目地址: git://github.com/DrVanScott/git-clone-init.git
创建时间: 2016-07-16T11:26:08Z
项目社区:https://github.com/DrVanScott/git-clone-init

开源协议:MIT License

下载


Automatic setup of user identity on git clone

Screenshot of a git clone

Whenever a repository is cloned, author information (user.email, user.name) is set according defined patterns. No longer pushing commits with your corporate email address by accident.

Installation

In case you do not already have a git template directory, create and register one:

  1. mkdir -p ~/.config/git/templates/hooks
  2. git config --global init.templatedir ~/.config/git/templates

Copy the file “post-checkout” to your registered git template directory:

  1. git clone https://github.com/DrVanScott/git-clone-init.git /tmp/git-clone-init
  2. cp /tmp/git-clone-init/post-checkout ~/.config/git/templates/hooks/

Copy a configuration template:

  1. cp /tmp/git-clone-init/git-clone-init ~/.config/git/templates/

Configuration

You can use the file git-clone-init as a starting point. Keep in mind to create a pattern for each protocol you are using, normally ssh and https.

Example:

  1. case "$url" in
  2. *@github.com:* ) email="my-public@email"; name="public name";;
  3. *//github.com/* ) email="my-public@email"; name="public name";;
  4. *@corp.com:* ) email="my-corporate@email"; name="real name";;
  5. *//corp.com/* ) email="my-corporate@email"; name="real name";;
  6. esac

Usage

Just do a normal “git clone” as usual.

Known issues

git-clone-init won’t work if you clone using “-n” or clone an empty repository.