将根本没有 VCS 的生产站点迁移到 Git

发布于 2024-11-03 19:59:26 字数 1836 浏览 0 评论 0原文

我想我会把这个扔出去,看看是否能得到一些可靠的建议。

我有一个具有相当大的代码库的生产站点,并且刚刚在其上安装了 Git,与测试站点相同。我有一个本地盒子,它基本上是集成点。我们的团队将推送到本地盒子,小侏儒会过来将所有内容转移到我们不同的服务器上 - 或者至少这是我实现 Git 的最接近的一次。

我真的不知道从哪里开始。一点点。我有一个庞大、挑剔的遗留代码库,在美好的一天我不敢碰它。 Git 是一个大清理过程的起点,我只是不知道如何开始。

我正在考虑基于我的生产文档根(带有适用的 .gitignore 内容)创建一个裸 .git 存储库,然后克隆到测试和开发环境,然后个人将克隆开发并开始工作,推回到开发,然后以某种方式当对裸存储库进行更改时,神奇地告诉 git 更新文档根目录。

我打算在开发中安装 git-flow (无法让它在我的生产服务器上工作),然后推送到生产环境。由于它们最终只是分支,我想我可以在生产/测试服务器上不使用 git-flow 。

这看起来一切都很好,我只是不知道我是否应该推动测试/生产,或者从开发拉到测试/生产。也许只是生产文档根目录中的直接 git init ?创建一个 .git 目录并 git init 到该目录? Git init git giggidy giggigdy ...

见解值得赞赏。

编辑

这就是我最终所做的,希望其他人会发现它有用。

将当前生产代码下载到开发服务器(LAMP) 设置 .gitignore 文件并在目录中运行 git init 并执行初始导入/提交
在登台/生产服务器上:
创建了 YOURNAME.git 目录并使用 git init --bare 创建了裸存储库
将工作树设置为 /path/to/my/public_html,将 bare 设置为 false,并将 receive.denycurrentbranch 设置为忽略
在 hooks/post-receive 添加了一行: git checkout -f 确保我的 git 用户有权写入工作树

返回开发服务器:
git远程添加[暂存|生产] ssh://myuser@myserver/path/to/my.git
git push [生产|生产] master

要更新我的生产和暂存站点,只需一个简单的git Push [生产|生产],我不必为隐藏而大惊小怪公共视图中的 .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。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赠意 2024-11-10 19:59:27

如果您对像 Capistrano 这样的重型部署解决方案不感兴趣,那么您可以在裸存储库上设置一个 post-receive 挂钩,以检查生产文档根目录中的最新更改。您可以为开发和生产设置一个单独的挂钩。这是执行此操作的非常好的指南

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文