2.0 alias命令别名提高操作效率

2019-06-11  本文已影响0人  黄刚刚

主要涉及的命令:git config --global alias

主要涉及的文件:.gitconfig

[root@localhost hd]# git config --global alias.a add

[root@localhost hd]# git a .

解释:定义一个命令别名a指向add,并且直接使用别名命令git a .,相当于执行了git add .

[root@localhost .git]# cd ~

[root@localhost ~]# ls -a

.  anaconda-ks.cfg  .bash_logout  .bashrc  git        .pki

..  .bash_history    .bash_profile  .cshrc  .gitconfig  .tcshrc

[root@localhost ~]# cat .gitconfig

[user]

        email = 532508307@qq.com

        name = Huang Cui Gang

[alias]

        a = add

解释:查看.gitconfig文件的内容,有[alias]字段显示了刚才添加的命令别名,接下我们直接编辑.gitconfig文件的[alias]字段为如下:

[alias]

        a = add

        c = commit -m

        s = status

        l = log

创建一个新文件

[root@localhost hd]# touch a.php

开始使用创建的别名命令

[root@localhost hd]# git s

# 位于分支 master

#

# 初始提交

#

# 未跟踪的文件:

#  (使用 "git add <file>..." 以包含要提交的内容)

#

#      a.php

提交为空,但是存在尚未跟踪的文件(使用 "git add" 建立跟踪)

[root@localhost hd]# git c "初次提交"

[root@localhost hd]# git l

commit 288a28487ef54f611f960c8a0735daef37bd95f1

Author: Huang Cui Gang <532508307@qq.com>

Date:  Tue Jun 11 11:21:04 2019 +0800

    初次提交

上一篇 下一篇

猜你喜欢

热点阅读