Git repo clone and multi-account manager
pnpm i -g tanyao
-
Init config on first use :
tanyao init
-
Config your
base
directory and git account info. -
Clone repo from anywhere :
tanyao clone https://github.com/xn-sakina/tanyao.git # or tanyao clone git@github.com:xn-sakina/tanyao.git # or ... tanyao clone https://github.com/xn-sakina/tanyao.git ./tmp-path
directory structure :
base ├── github.com │ └── xn-sakina │ └── tanyao └── gitlab.com └── owner └── repo
Open ~/.config/tanyao/config.json
, set up a code base
and git account info :
// ~/.config/tanyao/config.json
{
"base": "/Users/username/Documents/Code",
"codebase": [
{
"url": "github.com",
"username": "github-username",
"email": "i@domain.com"
},
{
"url": "gitlab.com",
"username": "gitlab-username",
"email": "admin@domain.com"
}
],
"alias": {
"github://": "https://github.com/"
}
}
# ~/.zshrc
alias -s git="tanyao clone"
This will make the :
$ https://github.com/xn-sakina/tanyao.git
# equal
$ tanyao clone https://github.com/xn-sakina/tanyao.git
See Suffix aliases (-s) in Zsh learn more.
// ~/.config/tanyao/config.json
{
"base": [
// use `process.env.CODE_BASE`
"{CODE_BASE}/dir",
// multiple `base`, select when clone
"Other/Codebase/Path"
]
}
example:
# .gitconfig
[includeIf "gitdir:~/code_base_name/"]
path = ~/.gitconfig-code_base_name
# ~/.gitconfig-code_base_name
[user]
name = github_user_id
email = github_email
[core]
excludesfile = ~/.gitignore_global
sshCommand = ssh -i ~/.ssh/id_ed25519
[init]
defaultBranch = main
See How to Use Two GitHub Accounts on a Macbook the Right Way
alias: -p
Show git clone progress.
alias: -d
Git clone depth.
- projj : Manage repository easily.
MIT