推送到webroot上的托管项目 [英] Pushing to Hosted project above webroot

查看:114
本文介绍了推送到webroot上的托管项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 CakePHP 应用程序托管在 DreamHost - 和本地在我的MacBook克隆。 p>

我试图设置我的环境,以便我可以在MacBook上开发,并根据需要推送到托管网站 - 但不知道如何设置<当远程文件位于 webroot 之上时,code> git 从本地推送到远程。



如何设置我的本地git来推送托管应用程序上的webroot上的文件?



谢谢!

解决方案


但是无法找出当远程文件在webroot之上时如何设置git从本地推送到远程。


要设置仓库,您需要一个中间仓库作为参考点。现在这个repo可以在一个托管网站如 github bitbucket ,或者可以是一个 bare repo 。 (注意 - bitbucket有少量用户的免费私人回复



bare repo 是你可以规避与设置 ssh相关的任何问题机制在服务器,在线服务和您的开发机之间。缺点是会丢失服务器上的所有代码,以防您的服务器出现故障,尽管您仍然会在开发机上拥有它的副本,因此不会全部丢失。



第1步



因此,让我们假设您继续进行裸回购。如果你将使用bitbucket / github,忽略这一步。



为此,我们需要在您的服务器上创建如下的裸存储:

  ssh user @ myserver 
cd / some / isolated / location
git init --bare intermediate_repo.git

这将创建一个具有路径 /some/isolated/location/intermediate_repo.git 的中间回购。



接下来,cd在这个裸存储库中,并运行以下命令,以便您可以通过ssh访问作为 git服务器

  cd intermediate_repo.git 
mv hooks / post-update.sample hooks / post-update
chmod a + x hooks / post-update
git update-server-info

现在你的 bare repo可以作为中间回购我们可以将其作为 远程 添加到其他存储库中。



第2步



现在在 / code>机器,添加远程(步骤2)

  git remote add intermediate ssh:// user @ myserver: /some/isolated/location/intermediate_repo.git 

步骤3



服务器的库中添加远程

  ssh user @ myserver 
cd / repo / location
git remote add intermediate /some/isolated/location/intermediate_repo.git

第4步



您可以从您的开发机推送您的代码如下:

  git push intermediate branchname 

并将其拖入您配置的代码库中

  ssh -t user @ myservercd / repo / location&& git pull intermediate branchname






> PS



如果您选择使用bitbucket安装,请跳过步骤1,并在上述步骤2和3中,使用bitbucket ssh url的 url / 路径查看这个bitbucket链接用于设置sbb访问,同时生成ssh密钥,



您的视图文件夹应该可供您使用位置 / repo / location / Views ,您可以配置为webroot访问。


I have a CakePHP app hosted on DreamHost - and a clone of it locally on my MacBook.

I'm trying to set up my environment so that I can develop on the MacBook and push to the hosted site as necessary - but can't figure out how to set up gitto push from local to remote when the remote files are above the webroot.

How do I set up my local git to push to files above webroot on the hosted app?

Thanks!

解决方案

but can't figure out how to set up git to push from local to remote when the remote files are above the webroot.

To setup the repos, you will need an intermediate repo to serve as the reference point. Now this repo could be on a hosting site like github or bitbucket, or it could be a bare repo on your server itself. (Note - bitbucket has free private repos for small number of users)

The advantage of a bare repo is that you can circumvent any issues related to setting up ssh mechanism between the server, the online service and your dev machine. The cons would be losing all the code on the server in case your server goes down, though you will still have a copy of it on your dev machine, so not all will be lost.

Step 1

So let us assume you move ahead with a bare repo. Ignore this step if you will be using bitbucket/github.

For this, we need to create a bare repo as follow on your server:

ssh user@myserver
cd /some/isolated/location
git init --bare intermediate_repo.git

This creates an intermediate repo with path /some/isolated/location/intermediate_repo.git.

Next, cd inside this bare repo, and run the following commands, so that you can access the repo over ssh as a git server

cd intermediate_repo.git
mv hooks/post-update.sample hooks/post-update
chmod a+x hooks/post-update
git update-server-info

So now your bare repo is good to go as the intermediate repo, and we can add it as remote in other repositories.

Step 2

Now in your dev machine, add a remote (Step2)

git remote add intermediate ssh://user@myserver:/some/isolated/location/intermediate_repo.git

Step 3

And on your servers repo, add a remote

ssh user@myserver
cd /repo/location
git remote add intermediate /some/isolated/location/intermediate_repo.git

Step 4

So now you are good to go ().

You can push your code as following from your dev machine

git push intermediate branchname

and pull it into your configured code repo as

ssh -t user@myserver "cd /repo/location && git pull intermediate branchname"


PS

If you choose to go with a bitbucket installation, then skip step 1, and in steps 2 & 3 above, replace the url/path with the bitbucket ssh url. Check out this bitbucket link for setting up ssh access with bitbucket. Also, while generating ssh keys, generate them without passphrases, otherwise you might have to debug more stuff around ssh and passphrases.

Your Views folder should be available to you at location /repo/location/Views, which you can configure for webroot access.

这篇关于推送到webroot上的托管项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆