定制Git命令

首先写个脚本文件,命名以git-开头

[root@git bin]# cat git-top-check

!/bin/sh

if [ -d ".git" ];then
echo "This is the highest directory of GIT"
exit 0
fi

    echo "This is not the highest directory of GIT"
    exit -1

[root@git bin]#

让这个脚本可以执行
[root@git bin]# chmod u+x git-top-check

把这个脚本文件放到/usr/bin/下

[root@git bin]# mv git-top-check /usr/bin/

测试!
在版本库里面测试

[root@git bin]# cd ~/git
[root@git git]# ls -la
total 20
drwxr-xr-x. 3 root root 4096 Dec 19 06:14 .
drwx--x--x. 32 root root 4096 Dec 19 06:59 ..
-rw-r--r--. 1 root root 34 Dec 19 03:58 aaaa.txt
drwxr-xr-x. 8 root root 4096 Dec 19 06:16 .git
-rw-r--r--. 1 root root 12 Dec 19 00:40 test.txt
[root@git git]# git top-check
This is the highest directory of GIT
[root@git git]#

可以看到,我们的定制生效了

在不是git版本库测试

[root@git git]# cd /tmp/
[root@git tmp]# git top-check
This is not the highest directory of GIT
[root@git tmp]#

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容