git - 在 cPanel 中创建 git repo 时出现问题

标签 git cpanel

我在将 repo 创建到 public_html 文件夹时遇到问题。它说这样的错误。

Error: You cannot use the “/home/clientresearch/public_html” directory because it already contains files.

有什么方法可以在已有文件的 cPanel 中创建 repo。现在它只在干净的目录中工作。 我们怎样才能让 git repo 拥有像 live 站点一样的所有文件?

提前致谢

最佳答案

您应该将 git 克隆和 public_html 部署文件夹分开。
克隆源代码库和部署其内容是两个独立的步骤。

这样,您可以按照 CPanel 指南“Guide to Git - Deployment”进行操作,其中包括:

The .cpanel.yml file determines how and where the changed files deploy.

You must check a .cpanel.yml file in to the top-level directory for each cPanel-managed repository that you wish to deploy.
.cpanel.yml files must use the format in the example below.

Important:

The file below is only an example. You must update it to suit your needs. It will not allow you to deploy a repository successfully.

The following .cpanel.yml file deploys the index.html and style.css files to the example account's public_html directory:

---
deployment:
  tasks:
    - export DEPLOYPATH=/home/user/public_html/
    - /bin/cp index.html $DEPLOYPATH
    - /bin/cp style.css $DEPLOYPATH

如果您想要部署 repo 的全部内容,请查看“Automatic or push deployment”部分

cPanel's Git Version Control feature (cPanel >> Home >> Files >> Git Version Control) automatically adds a post-receive hook to all cPanel-managed repositories.

When you push changes directly to a cPanel-managed repository that includes a .cpanel.yml file, the hook deploys those changes automatically.
For more information, read Git's githooks documentation.

https://documentation.cpanel.net/download/attachments/14002623/automatic_deployment.png?version=4&modificationDate=1539182581380&api=v2

关于git - 在 cPanel 中创建 git repo 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53942471/

相关文章:

git - 在 npm 包中使用非 npm-package git 子模块

git - 在私有(private)存储库中找不到 Composer 包

linux - 服务器加载时间问题

php - CENTOS 6.9 php soap 扩展已安装但无法正常工作

web - 如何防止自动创建 cgi-bin?

git - 仅构建已推送到的 Git 分支

无需推送/pull 存储库上的 git 版本控制文件

git - 从历史记录中删除大文件/在本地完全删除历史记录,然后将其推送到源

javascript - JS 音频不工作

java - 如何在cpanel中连接远程mysql连接