简体   繁体   English

使用Git将多个项目部署到服务器的最佳方法是什么?

[英]What's the best way to deploy multiple projects to a server with Git?

I am about to take the plunge and start using Git for actual projects that others use! 我即将采取行动并开始使用Git进行其他人使用的实际项目!

So far I've used Git on some basic projects and played around with Github for some university projects, but now me and some others will be working on multiple projects. 到目前为止,我已经在一些基础项目中使用了Git,并在Github上为一些大学项目进行了游戏,但现在我和其他一些项目将在多个项目上工作。 As a result we'll be hosting Git on a remote server and to be honest it'd be great if we could just get started on a tried-and-tested method of using Git for our needs. 因此,我们将在远程服务器上托管Git,说实话,如果我们能够开始使用Git来满足我们的需求,那就很好了。

At first we thought of hosting the Git master on the server, a la... 起初我们想过在服务器上托管Git master,一个...

Site: /home/vhosts/domain/htdocs 站点: / home / vhosts / domain / htdocs

Git: /home/git/domain.git Git: /home/git/domain.git

This sounds like it'd work, but I'm worried about hosting a repository on the server the main website is running from in case it goes down or if we lose data, as we'd be left with our local copies. 这听起来像它的工作,但我担心在主网站运行的服务器上托管一个存储库,以防万一它丢失或者我们丢失了数据,因为我们将留下我们的本地副本。 I'd like to have it all running on a development server, but some think that it is overkill and some thing that logistically it could be a nightmare. 我想让它全部在开发服务器上运行,但是有些人认为这有点过分,而且有些东西在逻辑上可能是一场噩梦。

To be fair, we're all recent graduates and have only basic experience with source control on hobby projects and solely on final-year CS projects, with the popular option at that time being subversion. 公平地说,我们都是刚刚毕业的学生,​​并且只拥有关于爱好项目的源头控制的基本经验,而且仅仅是最后一年的CS项目,当时流行的选择是颠覆。 One of the reasons we chose Git was through word-of-mouth from other developers and through recommendations of friends who use it extensively at work. 我们选择Git的原因之一是通过其他开发人员的口口相传以及在工作中广泛使用它的朋友的推荐。

To clarify, we will be working on multiple, hosted projects and would like to deploy using Git. 为了澄清,我们将处理多个托管项目,并希望使用Git进行部署。 What we're stuck on is on the best way to handle this. 我们坚持的是处理这个问题的最佳方法。 There will be around three of us working on separate machines at any one time with a live server and (hopefully) a development server to test stuff on. 我们中的大约三个人同时在不同的机器上使用实时服务器和(希望)开发服务器来测试内容。

For those who are dealing primarily with web applications, how do you use Git to deploy your working code to the server? 对于那些主要处理Web应用程序的人来说,如何使用Git将工作代码部署到服务器? Are we barking up the wrong tree for our needs? 我们是否因为需要而吠叫错误的树? Any tips you can give a Git novice? 你能给Git新手的任何提示吗?

The thing you need to understand is that all Git repositories are, essentially, "local". 您需要了解的是,所有Git存储库本质上都是“本地的”。

When you clone a repository using git clone , you are getting the entire repository with all of its changes and logs. 使用git clone克隆存储库时,您将获得包含其所有更改和日志的整个存储库。 If you lost the remote repository, your local clone can pick up right where the remote one left off. 如果丢失了远程存储库,则本地克隆可以直接从远程存储库中取出。

In addition, you could have multiple remote repositories attached to your local repository: for instance, when I'm working on a site, I'll have my own local repository, and a remote repository on both the development server and the production server. 此外,您可以将多个远程存储库附加到本地存储库:例如,当我在站点上工作时,我将拥有自己的本地存储库,以及开发服务器和生产服务器上的远程存储库。 Then, it's just a matter of pulling and pushing to the correct one depending on context. 然后,这只是根据上下文拉动和推动正确的问题。

And those remote repositories are nothing special: they're just directories containing the same things on my computer. 而那些远程存储库并不特别:它们只是在我的计算机上包含相同内容的目录。

So the only thing you need to worry about is making sure your remote repositories are accessible by every one on your team: if you don't have any other place to put it, the server you have the site on is fine. 因此,您唯一需要担心的是确保您的团队中的每个人都可以访问您的远程存储库:如果您没有任何其他地方可以放置它,那么您拥有该站点的服务器就可以了。

If you want to work with a (or different) team(s), you should look at Gitosis : it is a simple way to manage multiple Git projects with custom access rights (read/write) by user and by project. 如果你想与一个(或不同的)团队合作,你应该看看Gitosis :这是一个通过用户和项目管理具有自定义访问权限(读/写)的多个Git项目的简单方法。

A Gitosis tutorial: http://scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way Gitosis教程: http//scie.nti.st/2007/11/14/hosting-git-repositories-the-easy-and-secure-way

Another solution is Gitolite , a Gitosis evolution. 另一种解决方案是Gitolite ,一种Gitosis进化。

I actually wrote a blog post about the procedure I use to deploy my website from a local computer to a staging server and then the live site, since it's somewhat complicated. 我实际上写了一篇关于我用来将我的网站从本地计算机部署到登台服务器然后是现场网站的程序的博客文章 ,因为它有些复杂。 The writeup might be useful to you if you want to use a two-tier distribution architecture (staging server and then live server). 如果要使用双层分发体系结构(登台服务器,然后是实时服务器),则写入可能对您有用。 If you don't want to use a staging server, you can configure your local computer to push directly to the live site, and that's way simpler. 如果您不想使用登台服务器,可以将本地计算机配置为直接推送到实际站点,这样更简单。 Of course that setup would still allow you to test on your local computer. 当然,该设置仍然允许您在本地计算机上进行测试。

Other than that, I would echo what Mark Trapp said about the decentralized nature of git. 除此之外,我会回应马克特拉普关于git的分散性质所说的话。 There's no problem with putting your central repository on the web server, since your local copy contains everything you need to keep working and to reconstruct another central repository if necessary. 将中央存储库放在Web服务器上没有问题,因为本地副本包含了继续工作所需的一切,并在必要时重建另一个中央存储库。

We use gitosis to manage multiple repositories with multiple users: http://fclose.com/b/1432/setting-up-git-server-using-gitosis/ 我们使用gitosis来管理多个用户的多个存储库: http//fclose.com/b/1432/setting-up-git-server-using-gitosis/

Previously we use git through SSH connection. 以前我们通过SSH连接使用git。 That will make every one is the administrator. 这将使每个人都是管理员。 So we move to gitosis. 所以我们转向gitosis。 We can control who can write to one repository and who can read one repository. 我们可以控制谁可以写入一个存储库以及谁可以读取一个存储库。 And we can have several administrators. 我们可以有几个管理员。 We can also set up email notification scheme. 我们还可以设置电子邮件通知方案。 We are happy with it by now. 我们现在很高兴。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将git项目(带有子模块)部署到FTP服务器的最佳方法 - Best way to deploy git projects (with submodules) to FTP server 使用git时组织多个项目的最佳方法是什么 - What is the best way to organize multiple projects when using git 在多个master分支上使用git的最佳方法是什么? - What's best way to work with git on multiple master branch? 在 Git 中跟踪多语言项目的最佳方法是什么? - What is the best way to track multi language projects in Git? 从 SVN 切换 Git 上处理多个项目的最佳方法是什么? - Which is the best way to handle multiple projects on Git switching from SVN? 在具有相同基础的多个项目上使用git的最佳实践是什么? - What is the best practice for using git on multiple projects with the same base? 在git中强制合并的最佳方法是什么? - What's the best way to force a merge in git? 在 Heroku 上使用 git 部署大文件的最佳方法是什么? - What is the best way to deploy large files using git on Heroku? 从git部署的最佳方法 - Best way to deploy from git 使用Amazon AWS Elastic Beanstalk运行具有多个git存储库的平台的最佳方法是什么? - What's the best way to run a platform with multiple git repositories with Amazon AWS Elastic Beanstalk?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM