如何在 git 中给命令取别名? [英] How do I alias commands in git?

查看:43
本文介绍了如何在 git 中给命令取别名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到有人收到的截屏

git st
git ci

上班.当我这样做时,我收到一个错误,询问我是否有其他意思.
作为一个 git newb,我需要知道你必须做什么才能完成这项工作?

to work. When I do it I get an error asking me if I meant something else.
Being a git newb, I need to know what you have to do to get this done?

推荐答案

基本上你只需要在 ~/.gitconfig

[alias]
    st = status
    ci = commit -v

或者你可以使用 git config alias 命令:

Or you can use the git config alias command:

$ git config --global alias.st status 

在 unix 上,如果别名有空格,请使用单引号:

On unix, use single quotes if the alias has a space:

$ git config --global alias.ci 'commit -v'

在 Windows 上,如果别名有空格或命令行参数,请使用双引号:

On windows, use double quotes if the alias has a space or a command line argument:

c:dev> git config --global alias.ci "commit -v"

alias 命令甚至接受函数作为参数.看看别名.

The alias command even accepts functions as parameters. Take a look at aliases.

这篇关于如何在 git 中给命令取别名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆