LoginSignup
0
0

More than 5 years have passed since last update.

globalとは別のauthorでgit initしてくれるスクリプトを書いた。

Posted at

社用のパソコンなどで個人で開発下のものを個人用のgithubアカウントに送りたくなることが多々ある。
ところが、社用のパソコンの場合、デフォルトでは社内用のgitの設定をしているとそのまま個人用なのに会社で使っているauthorのままプッシュしてしまうことがある。
こうなってしまうと、後からauthor設定に修正したりするのが非常に面倒である。

なので、個人アカウントのauthor設定をinitと同時にしてしまうスクリプトを書いた。

まずは.bashrcなどに必要な個人用authorを環境変数として登録しておく。

.bashrc
export GITHUB_USER_NAME=github_author
export GITHUB_USER_EMAIL=github_author@mail.com

スクリプトの本体はこちら

githubinit
#! /usr/bin/env bash

git init
git config --local user.name $GITHUB_USER_NAME
git config --local user.email $GITHUB_USER_EMAIL

これをgit initの代わりに利用する。

$ mkdir test
$ cd test
$ touch text
$ githubinit
$ git add . && git commit -m "initial commit"
$ git log
commit -----
Author: github_author <github_author@mail.com>
Date:   Thu Jun 8 09:46:46 2017 +0900

    initital commit
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0