管理git别名的工具
git-alias的Python项目详细描述
git alias:管理git别名
git-alias
是管理git别名的工具。
安装
要安装发布版本的git-alias
:
pip install git-alias
或者直接从github安装:
pip install git+https://github.com/larsks/git-alias
git-alias
需要python 3.7或更高版本。
管理别名
列出别名
$ git alias list
conflicts
fix
please
pr
tracking
从本地文件安装
$ git alias -v install examples/pr.alias
INFO:git_alias.main:installing alias pr from examples/pr.alias
从git存储库安装
$ git alias -v add -R https://github.com/larsks/git-alias examples/pr.alias
INFO:git_alias.main:cloning https://github.com/larsks/git-alias
INFO:git_alias.main:installing alias pr from /tmp/aliasmylwfb93/examples/pr.alias
显示别名扩展
$ git alias show pr
!if [ $# -eq 1 ]; then set -- origin $1; elif [ $# -ne 2 ]; then echo
'Usage: git pr [<remote>] <pr>'; exit 2; fi; git fetch "${1}"
"+pull/${2}/head:pull/${1}/${2}"; git log -1 "pull/${1}/${2}" #
别名文件格式
空行和以#
开头的行将被丢弃。其余内容将在空格上联接。例如,此文件:
# Create a local branch from a pull request
#
# usage: git pr [<remote>] <pr>
#
# Get a pull request from origin:
#
# git pr 42
# git pr origin 42
#
# Either of the above would create local branch pull/origin/42.
#
# Get a pull request from another remote:
#
# git pr upstream 42
!if [ $# -eq 1 ]; then
set -- origin $1;
elif [ $# -ne 2 ]; then
echo 'Usage: git pr [<remote>] <pr>';
exit 2;
fi;
git fetch "${1}" "+pull/${2}/head:pull/${1}/${2}"; git log -1 "pull/${1}/${2}" #
在git配置文件中生成以下条目:
pr = "!if [ $# -eq 1 ]; then set -- origin $1; elif [ $# -ne 2 ]; then echo 'Usage: git pr [<remote>] <pr>'; exit 2; fi; git fetch \"${1}\" \"+pull/${2}/head:pull/${1}/${2}\"; git log -1 \"pull/${1}/${2}\" # "