将没有VCS的生产站点迁移到Git [英] Migrating a production site with no VCS at all to Git

查看:107
本文介绍了将没有VCS的生产站点迁移到Git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以为我会把它丢在那里,看看我是否可以得到一些坚实的建议。



我有一个生产网站有一个相当大的代码基地,刚刚安装了Git,与测试现场一样。我有一个本地的盒子,基本上是整合点。我们的团队将推送到当地的盒子,一点点的侏儒将会来到我们不同的服务器上,或者至少是我最接近实施Git的。



我真的没有从头开始的 线索。我有一个大而精巧的遗留代码库,我很害怕在一个美好的一天触摸。 Git是一个大的清理过程的起点,我只是不知道如何开始。



我正在考虑创建一个裸机.git repo根据我的生产docroot(使用适用的.gitignore内容),然后克隆到测试和开发环境中,然后个人将克隆dev并上班,推回到dev,然后以某种方式魔术般地告诉git更新docroot我将要开发git-flow(不能让它在我的生产服务器上工作),然后推送到生产。由于它们在一天结束时只是分支,所以我可以在prod / test服务器上不使用git-flow来消除。



这似乎都很好, ,我只是不知道我是否应该推动测试/产品,或从开发商拉到测试/产品。也许只是一个直接的git init在生产docroot?创建一个.git目录和git init? Git init git giggidy giggigdy ...



深入分析。



修改



这是我最后做的,希望有人会发现它很有用。



将当前生产代码下载到开发服务器(LAMP)
设置.gitignore文件,并在目录中运行 git init ,并初始化导入/提交

在分段/生产服务器上:

创建 YOURNAME.git 目录,并使用 git init --bare 创建裸存储库

将worktree设置为 / path / / my / public_html ,设置为false,并设置receive.denycurrentbranch以忽略

添加一行到hooks / post-receive: git checkout -f 确保我的git用户有权写工作单。



回到开发服务器上:

git remote add [staging | production ] ssh://myuser@myserver/path/to/my.git

git push [staging | production] master



要更新我的生产和分期站点,简单的 git push [production | staging] ,我不必担心从公共视图中隐藏一个.git目录。



资料来源:
http://www.deanoj.co.uk/programming/git/using-git-and-a-post-receive-hook -script-for-auto-deployment /

http:/ /toroid.org/ams/git-website-howto



希望这有助于某人!



再次编辑

另外,在1.7.3.3或更高版本上效果最好。我正在运行一个用于开发的虚拟化ubuntu框,并遇到了一些提交Samba的问题。在与此战斗数小时后,请阅读1.7.3.3中的问题。我在1.7.3.1。

解决方案

如果您不想进入像Capistrano这样的重型部署解决方案,那么您可以设置一个后接收钩在您的裸机箱中,检查您的生产文档的最新更改。您可以为开发人员和生产设置一个单独的钩子。这是一个相当不错的指南


I thought I would throw this out there and see if I could get some solid advice on this.

I've got a production site with a rather large code base and have just installed Git on it, same with test site. And I've got a local box that will basically be the point of integration. Our team will push to the local box and little gnomes will come and take everything off to our different servers - or at least that's the closest I've come to implementing Git.

I really don't have the slightest clue where to begin. I've got a big, finicky, legacy codebase that I am scared to touch on a good day. Git is meant to be the starting point of a big cleanup process, I just don't know how to get started.

I was thinking of creating a bare .git repo based on my production docroot (with applicable .gitignore stuff) and then cloning over to test and development environments, then individuals would clone off dev and get to work, pushing back to dev and then somehow magically telling git to update the docroot when changes to the bare repo are made.

I was going to install git-flow on development (can't get it to work on my production server), and then push to production. Since they are just branches at the end of the day, figured I could get away with not using git-flow on prod/test servers.

This seems all well and good, I just don't know if I should be pushing to test/prod, or pulling from dev to test/prod. Maybe just a straight git init in production docroot? Create a .git directory and git init to that? Git init git giggidy giggigdy...

Insights are appreciated.

Edit

Here's what I ended up doing, hopefully someone else will find it useful.

Downloaded current production code to development server (LAMP) Set up .gitignore files and ran git init within the directory and peformed initial import/commit
On Staging/Production servers:
Created YOURNAME.git directories and created bare repositories with git init --bare
Set worktree as /path/to/my/public_html, set bare to false, and set receive.denycurrentbranch to ignore
Added a line to hooks/post-receive: git checkout -f making sure that my git user had permission to write to the worktrees

Back on the development server:
git remote add [staging|production] ssh://myuser@myserver/path/to/my.git
git push [staging|production] master

To update my production and staging sites, its a simple git push [production|staging] and I don't have to fuss with hiding a .git directory from public view.

Sources: http://www.deanoj.co.uk/programming/git/using-git-and-a-post-receive-hook-script-for-auto-deployment/
http://toroid.org/ams/git-website-howto

Hope this helps someone!

Edit again
Also, works best on 1.7.3.3 or later. I'm running a virtualized ubuntu box for development and ran into some issues committing over Samba. After fighting with this for a couple of hours, read that the issue was fixed in 1.7.3.3. I was on 1.7.3.1.

解决方案

If you're not interested in getting into the heavier deployment solutions like Capistrano then you can set up a post-receive hook on your bare repository that checks out the latest changes into your production docroot. You could set up a separate hook for both dev and for production. Here is a pretty good guide to doing this.

这篇关于将没有VCS的生产站点迁移到Git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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