[英]Which default commands work in git-shell?
I log into git-shell with PuTTy using a password.我使用密码使用 PuTTy 登录 git-shell。 Whatever I type into the git-shell (the restricted login shell on a Debian linux server) results in a response like "unrecognized command".
无论我在 git-shell(Debian linux 服务器上的受限登录 shell)中输入什么,都会导致类似“无法识别的命令”这样的响应。
git> git help -a
unrecognized command 'git'
git-shell
is, by design, very limited. git-shell
的设计非常有限。 See the man page for more details.有关更多详细信息,请参阅手册页。
By default, it can only run a few commands, to allow for push/pull actions.默认情况下,它只能运行一些命令,以允许推/拉操作。 This is a way for git servers to offer "safe" SSH access that is limited to only interacting with git repositories.
这是 git 服务器提供“安全” SSH 访问的一种方式,该访问仅限于与 git 存储库交互。 Also by default, there is no interactive login access.
此外,默认情况下,没有交互式登录访问。
Note that simply to do push/pull/fetch operations using git-shell, you do not need to do anything special.请注意,只需使用 git-shell 执行push/pull/fetch操作,您不需要做任何特殊的事情。 It can already do those things.
它已经可以做这些事情了。 You only need to define custom commands if you want to do something unusual.
如果你想做一些不寻常的事情,你只需要定义自定义命令。
You say in comments that you have a ~/git-shell-commands/
directory, but it is empty.你在评论中说你有一个
~/git-shell-commands/
目录,但它是空的。 The presence of the directory will enable interactive mode, so you are getting a git>
prompt.该目录的存在将启用交互模式,因此您将收到
git>
提示。 However, that the commands directory is empty means there are no valid commands you can run.但是,命令目录为空意味着没有可以运行的有效命令。 In this scenario, the only thing you can run is
exit
to leave the shell.在这种情况下,您唯一可以运行的是
exit
以离开 shell。
To use git-shell
, you will need to create some commands in ~/git-shell-commands
.要使用
git-shell
,您需要在~/git-shell-commands
创建一些~/git-shell-commands
。 What exactly to create is up to you.究竟要创建什么取决于您。 An example might be to create
list
, and have that script return a list of the available repositories on the server.一个示例可能是创建
list
,并让该脚本返回服务器上可用存储库的列表。
If you want to use "standard commands," as you indicate in the comments, then I think the answer is that git-shell
is not the tool you are looking for.如果您想使用“标准命令”,正如您在评论中指出的那样,那么我认为答案是
git-shell
不是您正在寻找的工具。 It sounds like you are looking for a regular login shell.听起来您正在寻找常规登录外壳。
An example custom command might look like this.示例自定义命令可能如下所示。 Here's an implementation of the
list
command I suggested above.这是我上面建议的
list
命令的实现。
#!/bin/bash
# Assuming all repositories are named `*.git`
for repo in $(ls -d *.git); do
# Just in case one exists, ignore ".git"
if [[ "$repo" != ".git" ]];
# Trim off the extension
echo $(basename $repo .git)
fi
done
There are a couple of examples in this blog post . 这篇博文中有几个例子。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.