Local (per git)
$ cd git-repo $ git config user.name "Name Surname" $ git config user.email "name.surname@domain.com"Global
This method will override default or git's user configuration. Add following to .bashrc:
function gitswitch () {
    case "$1" in
    "custom")
        export GIT_AUTHOR_EMAIL="name.surname@domain.com"
        export GIT_AUTHOR_NAME="Name Surname"
        export GIT_COMMITTER_EMAIL="name.surname@domain.com"
        export GIT_COMMITTER_NAME="Name Surname"
        echo "Using custom configuration."
        ;;
    "default")
        unset GIT_AUTHOR_EMAIL
        unset GIT_AUTHOR_NAME
        unset GIT_COMMITTER_EMAIL
        unset GIT_COMMITTER_NAME
        echo "Using default configuration from .gitconfig."
        ;;
    *)
        echo "Bad argument - please specify 'custom' or 'default'."
        ;;
    esac
}
And then:$ gitswitch custom Using custom configuration. $ gitswitch default Using default configuration from .gitconfig. $ gitswitch ? Bad argument - please specify 'custom' or 'default'.
No comments:
Post a Comment