如何为 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,所以这个问题可能与软件版本无关。
关于linux - 使用 git-shell 的自定义命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14460967/