加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 使用git-shell的自定义命令

发布时间:2020-12-14 01:04:06 所属栏目:Linux 来源:网络整理
导读:如何为git- shell创建自定义命令?根据 documentation: When -c is given,the program executes non-interactively; can be one of git receive-pack,git upload-pack,git upload-archive,cvs server,or a command in COMMAND_DIR. The shell is started in
如何为git- shell创建自定义命令?根据 documentation:

When -c is given,the program executes non-interactively;
can be one of git receive-pack,git upload-pack,git
upload-archive,cvs server,or a command in COMMAND_DIR. The shell is
started in interactive mode when no arguments are given; in this case,
COMMAND_DIR must exist,and any of the executables in it can be
invoked.

但是,我不确定我是否正确理解这一点.我创建了一个名为gituser的用户,并将/usr/bin/git-shell作为shell.我创建了一个名为git-shell-commands的目录,并在其中放入了一个名为“testy”的脚本,但我无法通过git-shell运行它.

这是我正在尝试从另一台机器:

$ssh gituser@server.com testy
fatal: unrecognized command 'testy'

请注意,git-shell正在运行,并且响应,它无法找到我的自定义命令.

以下是脚本:

:/home/gituser/git-shell-commands# ls -l -a
total 12
drwxr-xr-x 2 gituser gituser 4096 Jan 22 17:35 .
drwxr-xr-x 4 gituser gituser 4096 Jan 22 13:57 ..
-rwxr-xr-x 1 gituser gituser   26 Jan 22 13:58 testy
:/home/gituser/git-shell-commands# ./testy
hello!
:/home/sodigit/git-shell-commands# cat testy
echo "hello!"

我究竟做错了什么?如何使用git-shell运行自定义命令?

解决方法

事实证明,这个功能已经在git 1.7.4中引入.我正在使用debian squeeze,它包含一个旧版本的git,所以这就是为什么它不起作用.

如果您遇到此问题,请检查您的git版本.

但是,从git 1.7.10开始,自定义命令仅在交互模式下工作,而不在-c中工作.我没有尝试过最新的git,所以这个问题可能与软件版本无关.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读