Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于wordpress部署的服务器上从本地repo到远程repo的Git推送_Wordpress_Git_Repository_Local_Remote Server - Fatal编程技术网

用于wordpress部署的服务器上从本地repo到远程repo的Git推送

用于wordpress部署的服务器上从本地repo到远程repo的Git推送,wordpress,git,repository,local,remote-server,Wordpress,Git,Repository,Local,Remote Server,尽管在这个主题上找到了最少的一致文档,但我的理解是,当您将git提交从本地存储库推送到服务器上的远程存储库(我的远程存储库位于bluehost服务器上)时,文件会被压缩,因此,它们不会以正常形式立即在服务器上可见 我成功地使用了一种方法来查看这些文件“未压缩”,即克隆存储库。然而,我试图在工作流系统中使用本地回购和远程回购来维护wordpress网站。当我将提交从本地repo推送到远程repo时,我无法通过浏览器访问该站点。为了通过浏览器访问文件的未压缩版本,是否还需要执行我缺少的其他步骤 每次

尽管在这个主题上找到了最少的一致文档,但我的理解是,当您将git提交从本地存储库推送到服务器上的远程存储库(我的远程存储库位于bluehost服务器上)时,文件会被压缩,因此,它们不会以正常形式立即在服务器上可见

我成功地使用了一种方法来查看这些文件“未压缩”,即克隆存储库。然而,我试图在工作流系统中使用本地回购和远程回购来维护wordpress网站。当我将提交从本地repo推送到远程repo时,我无法通过浏览器访问该站点。为了通过浏览器访问文件的未压缩版本,是否还需要执行我缺少的其他步骤


每次推送后是否必须将存储库克隆到同一文件夹?

我在Bluehost上有一个网站,设置起来非常简单。首先,您需要进入CPanel并请求ssh访问

然后按照本指南设置私钥(保留在计算机上)和公钥(在bluehost服务器上的.ssh/authorized_keys中)

我在主目录下设置了一个名为git的目录,并设置了一个test.git项目。请注意,我使用~/test作为我的工作树,因为我不想将文件推送到我的www中。您将使用~/www

*****@******.info [~]# 
*****@******.info [~/git]# mkdir test.git
*****@******.info [~/git]# cd test.git
*****@******.info [~/git/test.git]# pwd
/home1/******/git/test.git
*****@******.info [~/git/test.git]# git init --bare
Initialized empty Git repository in /home1/*******/git/test.git/
*****@******.info [~/www/test.git]# cd hooks
*****@******.info [~/www/test.git]# vi post-receive
post接收文件:

#!/bin/sh
GIT_WORK_TREE=/home1/*******/test git checkout -f
将文件保存为:x

*****@******.info [~/www/test.git/hooks]# chmod +x post-receive
*****@******.info [~/www/test.git/hooks]# cd ~
*****@******.infoo [~]# git init test
Initialized empty Git repository in /home1/*******/test/.git/
*****@******.info [~]# exit
回到我的本地计算机上:

[nedwidek@yule ~]$ git init test.git
Initialized empty Git repository in /home/nedwidek/test.git/.git/
[nedwidek@yule ~]$ cd test.git
[nedwidek@yule test.git]$ touch testfile.txt
[nedwidek@yule test.git]$ git add .
[nedwidek@yule test.git]$ git commit -m "testing" .
[master (root-commit) 1d6697c] testing
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 testfile.txt
[nedwidek@yule test.git]$ git remote add origin *****@******.info:/home1/*****/git/test.git
[nedwidek@yule test.git]$ git push -u origin master
Counting objects: 5, done.
Writing objects: 100% (3/3), 270 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To *****@******.info:/home1/*******/test.git
   f144186..0fd10f8  master -> master
Branch master set up to track remote branch master from origin.

我检查并将testfile.txt放在~/test/

中。如果您的本地计算机是windows,您将需要安装完整的PuTTY发行版和setup pageant来管理密钥。然后您可以使用Ortoisegit作为git客户端。git_Work_树必须指向与存储库不同的位置?是的,存储库与工作树不同。它实际上看起来不像本地git存储库(除了git文件之外,没有其他文件)。在这种情况下,您的工作树就是您的www目录(或者,当您从本地计算机进行git推送时,您需要文件副本的地方。我会向您展示我的文件,但在发布这些说明后,我将其删除了。回答很好,很详细,但我很好奇这是否是多个开发人员使用git工作流的最佳做法?我听说您应该在我相信这也允许您控制服务器上的合并,而不是推送和无法控制以后文件合并的方式