zeeshan / git-profile
实时更改 git 配置
v2.1.1
2017-03-14 16:31 UTC
Requires
- php: >=5.5.9
- symfony/console: ^3.1
- symfony/process: ^3.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ~2.0
- kherge/box: ~2.5
- symfony/phpunit-bridge: ^3.2
This package is not auto-updated.
Last update: 2024-09-14 19:42:15 UTC
README
git-profile
一个帮助您轻松切换 git 配置的实用工具
前言
您可能有多个 git 配置。例如
; Office Profile
Name: John Doe
Email: johndoe@office.com
; Personal Profile
Name: John Doe
Email: johndoe@gmail.com
当在不同的项目上工作时,记住和切换这些配置可能很麻烦。
这个实用工具旨在使这个过程不再麻烦。
功能
- 全局创建和管理配置文件;创建一次,任何地方都可以使用
- 为特定项目设置配置文件
- 使用单个命令设置全局配置文件
此实用工具可以帮助您保存配置文件,然后您可以使用单个命令在它们之间切换。
安装
$ composer global require zeeshan/git-profile
然后检查您的 $PATH
变量。它必须包含 ~/.composer/vendor/bin
目录。
$ echo $PATH
/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/home/username/.composer/vendor/bin
如果您的 $PATH
变量不包含 composer/bin 目录,请修改您的 .zshrc
或 .bashrc
文件。
export PATH=~/.composer/vendor/bin:$PATH
您还可以使用 .phar 文件
- 从这里下载文件
sudo chmod -R 755 git-profile
sudo mv git-profile /usr/local/bin/git-profile
用法
$ git-profile [options] <command>
选项
-h, --help Display this help message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
命令
rm Remove git profile
use Change git profile locally or globally
add Create a new git profile
show Show details for an existing profile
update Update details for an existing profile
current Gets the currently set profile
list List of profiles
示例
以下是一些示例用法
添加配置文件
$ git-profile add
[+] Enter profile title: Office
[+] Enter Name: John Doe
[+] Enter Email: johndoe@office.com
[+] Enter Signingkey: B7156A83
[OK] Profile "Office" saved successfully
删除 Git 配置文件
$ git-profile rm "Office"
[OK] Profile "Office" successfully removed
显示配置文件的详细信息
$ git-profile show "Office"
[+] Name: John Doe
[+] Email: johndoe@office.com
[+] Signingkey: B7156A83
更新配置文件
$ git-profile update "Office"
[+] Enter Name: Jane Doe
[+] Enter Email: janedoe@gmail.com
[+] Enter Signingkey: 547ABB1C
[OK] Profile "Office" updated successfully
切换配置文件
在本地设置详细信息,即设置当前项目的配置文件
$ git-profile use "Office"
[OK] Switched to "Office"
全局设置详细信息,即设置全局配置
$ git-profile use "Office" --global
[OK] Switched to "Office"
获取当前配置文件
$ git-profile current
[+] Current Profile "Office"
[+] Name: John Doe
[+] Email: johndoe@gmail.com
[+] Signingkey: 547ABB1C
备注 应注意,配置文件是全局维护的。当您在本地使用某个配置文件时,它会获取该配置文件的配置并将其设置为当前项目。即当在本地运行 use
时,相当于
$ git config user.name "Name for specified profile"
$ git config user.email "email-for-specified@profile.com"
$ git config user.signingkey "SIGNINGKEY"
配置文件列表
$ git-profile list
Available profiles:
Github
Home
Office
许可协议
MIT © Zeeshan Ahmad