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

标签 linux git shell ssh

如何为 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/

相关文章:

git - 将 Git 根文件夹内容更改为子文件夹

git - 查找在提交之间发生更改的目录

c++ - 在 Visual Studio 中为远程环境使用自定义构建命令

c - 我应该为我的应用程序使用进程还是线程?

linux - 如何在 ~/.bashrc 中使用 chmod

linux - 如何从 awk 中的变量中修剪空格?

linux - 如何将 bash 脚本的执行限制为特定用户

c++ - 静态、共享和可执行 - Windows 和 Linux

git - 我可以将本地分支映射到git中具有不同前缀的远程分支吗?

bash - 使用 Bash 时需要转义哪些字符?