我在将 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 theindex.html
andstyle.css
files to the example account'spublic_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.
关于git - 在 cPanel 中创建 git repo 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53942471/