【问题标题】:Avoid case sensitive in SSH commands避免在 SSH 命令中区分大小写
【发布时间】:2020-01-01 09:53:13
【问题描述】:

我已将我的 GitHub 存储库克隆到服务器,为了运行第二个命令,我发现文件夹问题:

逻辑

Repository 将在新文件夹匹配名称中克隆到服务器,如 repo 名称:

public_html > Resto

然后我需要输入 Resto 文件夹才能运行我的第二个命令,但它会返回

No such file or directory 

代码

$command1 = 'cd '.$destination.''; //get public_html folder
$command2 = 'git clone '.$repos->repository.''; //clone repo in public_html (it creates new folder same as repo name)
$command3 = 'cd '.$repos->name.''; //get repo name and enter new folder same as repo name
$command4 = 'composer install'; //run new command in repo folder

问题

这里的问题是 GitHub 将名称命名为 resto,而我的 public_html 中创建的文件夹命名为 Resto,因此涉及大写字母 R

我需要什么

我需要让我的$command3 忽略大小写并输入该文件夹,无论R 是否大写或文件夹名称中是否有空格(用于将来的其他克隆)

我该怎么做?

【问题讨论】:

  • 而不是“如何让我的代码使用错误的名称而不出错”,为什么不问“如何使用正确的名称”呢? $repos->name 来自哪里?你知道git clone 的下一个参数吗?
  • $repos->name 来自 github ssh https 链接它是存储库的名称
  • @Amadan 我的克隆部分工作得很好,它克隆了我的存储库。我的问题是进入该存储库文件夹
  • $repos->repository 的确切值是多少。 github 和 git 都不会随机大写字母。
  • 我的意思是,如果你使用git clone '.$repos->repository.' '.$repos->name;,你会得到你想要的目录。

标签: php ssh


【解决方案1】:

你可以specify where to clone:

git clone <repository> [<directory>]

【讨论】:

  • 会不会自动进入目录?
猜你喜欢
  • 2018-11-04
  • 2018-01-25
  • 1970-01-01
  • 1970-01-01
  • 2017-05-19
  • 1970-01-01
  • 2012-07-02
  • 2015-01-21
  • 1970-01-01
相关资源
最近更新 更多