Auto config diffient user.name and user.email in different git repos.
✨✨✨ Don't worry about forgetting to switch git info again!!!.
There is always a need to use a different user.name and user.email in different git repos. For example, your company's repo want to use your company's username and email, but your personal repo want to use your personal name and email.
Firstly, you need to config your rules by gitp p -r xxx -a xxx
. Then, when you clone a repo by gitp clone
, it will use your rules and auto to exec git config --local xxx
.
npm install -g git-auto-config
# or
yarn global add git-auto-config
# or
pnpm install -g git-auto-config
# mac
alias git="gitp"
# or
vim ~/.zshrc
alias git="gitp"
# window
to google~
only config once
# match git repository url contains `github`
gitp p -r "github" -a "name1 <email1@xx.com>"
# match git repository url contains `gitlab`
gitp p -r "gitlab" -a "name2 <email2@xx.com>"
# Then this repository will be auto config --local user.name and user.email use `name1 <email1@xx.com>`
gitp clone https://github.com/xxx/xxxx.git
# Then this repository will be auto config --local user.name and user.email use `name2 <email2@xx.com>`
gitp clone https://gitlab.com/xxx/xxxx.git
# Provided that you have already configed your git rules by `gitp p xxx`
gitp s
add git proxy rules
-r, --rule <rule>
-n, --name <name>
-e, --email <email>
-a, --author <author>
e.g.
gitp p -r github -a "name1 <email1@xx.com>"
# or
gitp p -r github -n name1 -e email1@xx.com
manual set current project(Make sure you had set the rule by gitp p xxx
)
e.g.
gitp s
# or
gitp set
show your config
-l, --list
-r, --rule <rule>
e.g.
# show rule `github` config
gitp ps -r github
# show all
gitp ps
delete your config
[...rules]
-a, --all
e.g.
# delete rule `github` and `gitlab`
gitp pd github gitlab
# delete all
gitp pd -a
e.g.
gitp -v
gitp -h
gitp p -h
gitp ps -h
gitp pd -h
Of course, you can continue use all the git command by gitp xxx
, that's the same with git
.
MIT License © 2022-PRESENT ChpShy