初始化生产服务器上的私有存储库 [英] Initializing private repositories on production server

查看:114
本文介绍了初始化生产服务器上的私有存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在想要做的是将我的生产服务器上的私有存储库初始化到应用程序的www文件夹(例如:/var/www/app.com/web/),然后将其作为临时存储库克隆到我的测试网站(例如:/var/www/test.com/web/app.com/)以及finaly从暂存到本地的克隆来处理代码。



我是计划它是正确的方式吗?



我正在关注这些教程,以了解更多关于设置git服务器和初始化私人存储库的信息:





最后一个问题,关于成功的Git分支模型的这篇教程适用于哪里?在主私人存储库(生产服务器)上,本地还是混合?我还没有完全阅读,我会尽快完成。



编辑:


我的计划是正确的吗?

级联回购听起来相当复杂,并且不正常。



考虑任何您正在提交的裸git回购的客户端/卫星/子结账。你的登台和制作安装应该是特定分支的只读结账,你可能已经很熟悉了(因为几乎所有的git问题都可以链接到它 - 现在这个问题也不例外)与 git-flow ,它可以让你了解如何设置你的分支并适当地结账。

b
$ b

Git服务器设置

本教程可能是您需要关注的唯一一个。



请注意,如果你在 / home / git 的家中设置git用户,并在 / home / git / project.git 这意味着你不需要绝对路径。即

 (服务器)$ cd / home / git 
(服务器)$ mkdir project.git
服务器)$ cd project.git
(服务器)$ git --bare init

然后

 (home)$ git clone git @ server:project.git 

当然,你也可以把你的git repos放到你想要的地方,然后改变git用户的home dir(在 / etc / passwd )来实现。

更新推送



如果您希望在推送到存储库时更新签出,则需要一个post-receive挂钩来完成。首先正确设置自己:

 (服务器)$ cd /var/www/app.com/web/ 
(服务器)$ git clone -b生产分支/home/git/project.git。 #它是本地的 - 使用文件路径
(服务器)$ cd /var/www/test.com/web/app.com/
(服务器)$ git clone -b staging-branch / home / git / project.git。

然后用

创建/home/git/project.git/hooks/post-update

  cd /var/www/test.com/web/app.com 
git --git-dir / var / www / test.com/web/app.com/.git拉#> / dev / null 2>& 1& #b


$ b $ p

    确保: >
  • 钩子文件是可执行的并且由git拥有

  • Git与检出文件的所有者位于同一个组中,否则您将获得当你推送时,许可错误



如上所述,命令的输出将在每次推送时发送给您,慢(ISH)。当你确定它能正常工作时,你可以在后台运行它。无论如何,暂存结账都在推动每一次推动 - 如果它指向的分支没有改变,它将不会执行任何操作。



这可能不是自动更新您的现场网站的好主意。相反

 (home)$ git checkout production-branch 
(home)$ git merge staging-branch
(home)$ git push#更新生产分支
(home)$ git checkout feature / i-was-working-on-this-
(home)$ ssh server'cd / var / www / app.com/web/; git pull'
#手动发布更新检查

如果您自动执行此操作,例如更新使您的生产网站处于不可用状态 - 您可能不知道(除非您获得 pingdom 通知,并提示生产站点离线)。如果您拥有重要的测试覆盖率和自动化部署流程,那么自动更新您的现场网站是安全的 - 但在运行之前先行走:)。

直接如果您设置




您可以如果您真的想进入非结帐结帐, pre> [receive]
denyCurrentBranch =忽略

在项目的.git / config文件中,如果没有本地更改也应更新工作副本(iirc)。


What I want to do now is to initialize a private repository on my production server in to app's www folder (ex: /var/www/app.com/web/) and then clone it as a staging repository to my testing site (ex: /var/www/test.com/web/app.com/) and finaly clone from staging to local to work with the code.

Am I planning it the right way?

I am following these tutorials to learn more about setting the "git server" and initialize private repositories:

One last question, this tutorial about A Successful Git Branching Model where would apply? On the main private repository (production server), local, or mixed? I haven't read it completely yet, I'll do it asap.

EDIT:

  • If it matters, I am trying to do so on a server running ISPConfig configuration.
  • It's not a must to work/be as mentioned above, if there is a "healthier" way... glad to learn about it.

This http://www.howtoforge.com/the-perfect-subversion-server-debian-lenny-ispconfig-3 and this http://www.howtoforge.com/installing-subversion-and-configuring-access-through-different-protocols-on-ubuntu-11.10 to GIT version is what I kinda had in mind

解决方案

Am I planning it the right way?

The cascading repos sounds quite complex, and is not normal.

Consider any checkout a client/satelite/child of the bare git repo you are committing to. Your staging and production installs should be read-only checkouts of specific branches, you are perhaps already familiar (because almost all git questions get a link to it - this question now being no exception) with git-flow which may give some insight into how to setup your branches and therefore checkouts appropriately.

Git Server Setup

This tutorial is probably the only one you need to follow.

Note that if you setup the git user with a home at /home/git and create a repo at /home/git/project.git that means you don't need absolute paths. I.e.

(server) $ cd /home/git
(server) $ mkdir project.git
(server) $ cd project.git
(server) $ git --bare init

Then wherever you want it:

(home) $ git clone git@server:project.git

of course, you could also put your git repos wherever you want and just change the git user's home dir (in /etc/passwd) to achieve the same.

Update on push

If you want to update a checkout whenever you push to a repository, you need a post-receive hook to do it. First set your self up correctly:

(server) $ cd /var/www/app.com/web/
(server) $ git clone -b production-branch /home/git/project.git . # it's local - use a file path
(server) $ cd /var/www/test.com/web/app.com/
(server) $ git clone -b staging-branch /home/git/project.git .

Then create /home/git/project.git/hooks/post-update with

cd /var/www/test.com/web/app.com
git --git-dir /var/www/test.com/web/app.com/.git pull #> /dev/null 2>&1 & #uncomment after testing

Ensure that:

  • The hook file is executable and owned by git
  • Git is (also) in the same group as the owner of the checked out files otherwise you'll get permission errors when you push

As written above the output of the command will be sent to you every time you push, which will make pushing slow(ish). You can run it in the background when you're sure it works correctly. It won't matter that staging checkout is pulling on every push - if there's no changes to the branch it's pointing at, it won't do anything.

It's probably not a good idea to update your live site automatically. Instead

(home) $ git checkout production-branch
(home) $ git merge staging-branch
(home) $ git push # updating production-branch
(home) $ git checkout feature/i-was-working-on-this
(home) $ ssh server 'cd /var/www/app.com/web/; git pull'
# Manual Post update checks

If you did that automatically and for example the update left your production site in an unusable state - you may not know (until/unless you get a pingdom alert saying "Production site offline"). It would be safe to automate updating your live site if you've got significant test coverage and an automated deploy process - but walk before running :).

Direct push

You can if you really want to push into a not-bare checkout if you set

[receive]
    denyCurrentBranch = ignore

In the project's .git/config file, if there are no local changes that should also update the working copy (iirc).

这篇关于初始化生产服务器上的私有存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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