How to set alias with parameters in git
PHP中文网
PHP中文网 2017-06-07 09:23:40
0
2
974

When setting alias in git, how to set the command with parameters?
For example, I have the command:
git log --all | grep "parameters"
My existing alias method is:
alog = log --all
When used, it is:
git alog | grep "parameters"
I want to know if there is a better way, you can merge grep into the alias, so that When using it, you only need to enter the
alias parameter?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
世界只因有你

The alias of git can only be set in git. prep is not a git command, so it will not work.

If you need to use this command, you can set a shell alias.

For example

glag = git log --all | grep

When using


glag "参数"

(Note that there is no git in front, because this is not an alias of git, but an alias of shell)

Recommend oh-my-zsh

伊谢尔伦

You can define an sh function as an alias, such as

# https://github.com/jokester/dotted/blob/master/DOTgitconfig#L22
# 把或HEAD的commit打包成txz
[alias]
     txz = !"foo () { if [ -n \"\" ]; then treeish=\"\" ; else treeish=HEAD; fi; git archive \"$treeish\" | xz -9 ; } ; foo "
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!