如何开始使用版本控制和 PHP
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/535056/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get started with version control and PHP
提问by alex
I have absolutely no idea about version control. Only that it can be very useful in many ways.
我完全不知道版本控制。只是它在很多方面都非常有用。
I have found a few related questions but none that start from the absolute beginning.
我发现了一些相关的问题,但没有一个是从绝对开始的。
I am the only developer at my work using Mac OS X and traditionally just been using FTP.
我是我工作中唯一使用 Mac OS X 的开发人员,并且传统上只使用 FTP。
Can anyone help me with version control in relation to PHP projects (does it matter)?
任何人都可以帮助我进行与 PHP 项目相关的版本控制(重要吗)?
回答by lpfavreau
Yes, try it out, it's worth it. And the language you are using doesn't matter. It's working great with PHP for me and it will for you too.
是的,试试看,这是值得的。您使用的语言并不重要。它对我来说非常适合 PHP,对你也一样。
Benefits
好处
If you are the only developer, it is indeed easier to go without version control. However, you will find great benefits to using a version control system. Some of the easiest benefits will be:
如果您是唯一的开发人员,那么没有版本控制确实更容易。但是,您会发现使用版本控制系统有很大的好处。一些最简单的好处是:
- Never wondering what is your latest version once you go back to a project (no more myproject090201-archive2-final6.zip)
- Never fear to start off some major refactoring, if you make a mistake on your file, you'll just rollback to the latest version
- If something stops working in your project and you have the feeling it worked at one point, you can test some of the prior versions easily and look at the difference between the working version and the non-working version to find what broke the code
- Additional backup of your current project, and even better if it's not on your machine... of course, additional points for backing up your version control system, we're never too cautious, you don't want to have to restart that month-long project do you?
- 一旦你回到一个项目,永远不要想知道你的最新版本是什么(不再是 myproject090201-archive2-final6.zip)
- 永远不要害怕开始一些重大的重构,如果你的文件出错,你只会回滚到最新版本
- 如果您的项目中的某些内容停止工作并且您感觉它在某一时刻起作用,您可以轻松测试一些以前的版本并查看工作版本和非工作版本之间的差异以找出破坏代码的原因
- 对你当前项目的额外备份,如果它不在你的机器上就更好了......当然,备份你的版本控制系统的额外点,我们永远不会太谨慎,你不想在那个月重启-长期项目吗?
Choices
选择
As some have said, you have a few choices for your version control system and I guess you'll want a free one to begin. There are a few excellent commercial products but the free ones have nothing to be ashamed of. So here are some very popular free version control systems:
正如一些人所说,您的版本控制系统有几种选择,我想您会想要一个免费的开始。有一些优秀的商业产品,但免费的没有什么可耻的。所以这里有一些非常流行的免费版本控制系统:
- Subversion(also called SVN)
- Git
- Mercurial
- Bazaar
Centralized versus distributed
集中式与分布式
Subversion has been there for a while and it's one classified as 'centralized'. Meaning everyone will always go fetch the latest version and commit their latest work to one central system, often on another system although it can easily be on your own machine. It's a process easy to understand.
Subversion 已经存在一段时间了,它被归类为“集中式”。这意味着每个人总是会去获取最新版本并将他们的最新工作提交到一个中央系统,通常在另一个系统上,尽管它可以很容易地在你自己的机器上。这是一个很容易理解的过程。
The three others are called 'distributed'. There's a lot of different possible processes as it's a more flexible system and that's why those three newcomers are getting a lot of traction these days in open source projects where a lot of people are interacting with one another. Basically you are working with your own revisions on your own machine, making as many copies as you need and deciding which versions you share with other people on other computers.
其他三个被称为“分布式”。有很多不同的可能流程,因为它是一个更灵活的系统,这就是为什么这三个新人如今在许多人彼此交互的开源项目中获得了很大的吸引力。基本上,您是在自己的机器上处理自己的修订,根据需要制作尽可能多的副本,并决定与其他计算机上的其他人共享哪些版本。
The trend definitely seems go towards distributed system but as those systems are more recent, they are still missing the GUI tools that makes it really user friendly to use and you might sometimes find the documentation to be a bit lighter. On the other hand, this all seems to be getting corrected quickly.
趋势肯定是趋向于分布式系统,但由于这些系统是较新的,它们仍然缺少 GUI 工具,这使得它使用起来非常用户友好,有时您可能会发现文档有点轻。另一方面,这一切似乎正在迅速得到纠正。
In your case, as you are working alone, it probably won't make a big difference, and although you'll hear very good points for centralized and distributed systems, you'll be able to work with one or the other without any problems.
在您的情况下,由于您是单独工作,因此可能不会有太大的不同,尽管您会听到集中式和分布式系统的优点,但您可以毫无问题地与其中一个一起工作.
Tools
工具
If you absolutely need a GUI tool for your Mac, I'd then choose SVN to get initiated to source control. There are two very good products for that (commercial):
如果您绝对需要 Mac 的 GUI 工具,那么我会选择 SVN 来启动源代码控制。有两种非常好的产品(商业):
And a few other ones(such as the free svnX) that are becoming a little bit old and unfriendly in my opinion but that might be interesting trying anyway.
还有一些其他的(例如免费的svnX)在我看来变得有点陈旧和不友好,但无论如何尝试可能会很有趣。
If you don't mind not using the GUI tools, with the help of Terminal you'll be able to do all the same things with a few simple command lines with any of the aforementioned systems.
如果您不介意不使用 GUI 工具,在终端的帮助下,您将能够使用上述任何系统通过几个简单的命令行执行所有相同的操作。
Starting points
起点
In any cases, you'll want some starting points.
在任何情况下,您都需要一些起点。
For Subversion, your first stop must be their free book, Version Control with Subversion. Take a few hours of your day to go through the chapters, it'll be time well invested. The introduction chapters are a good read even you don't want to use Subversion specifically because it'll get you to understand version control a little bit better.
For a distributed system, I've had fun with Mercurial but it's an easily flammable subject so I'll let you make your own choice there. But if you end up looking at Mercurial, have a look at this blog post, it was an excellent starter for me that'll get you up and running with the basics in a few minutes if you're already a bit accustomed to version control in general. Anyway, drop by Mercurial's homepageand have a look at the Getting Started section of the page.
对于 Subversion,您的第一站必须是他们的免费书籍《使用 Subversion 进行版本控制》。每天花几个小时来阅读这些章节,这将是值得投资的时间。即使您不想专门使用 Subversion,介绍章节也值得一读,因为它会让您更好地理解版本控制。
对于分布式系统,我对 Mercurial 很感兴趣,但它是一个容易燃烧的主题,所以我会让你在那里做出自己的选择。但是,如果您最终查看 Mercurial,请查看这篇博文,它对我来说是一个很好的入门,如果您已经有点习惯于版本控制,它可以让您在几分钟内开始使用基础知识一般来说。无论如何,请访问Mercurial 的主页并查看页面的入门部分。
Conclusion
结论
Give it a go, invest a day trying it out with a few bogus files. Try out renaming files and directory, erasing, moving things around, committing binary files versus text files, resolving conflicts and reverting to older versions to get a hang of it. These are often the first few hurdles you'll encounter when playing with version control and it'll be painless if it's on a non-production project.
试一试,花一天时间用一些假文件尝试一下。尝试重命名文件和目录、擦除、移动内容、提交二进制文件与文本文件、解决冲突并恢复到旧版本以掌握它。这些通常是您在使用版本控制时首先会遇到的几个障碍,如果是在非生产项目中,这将是轻松的。
In any cases, it's something well-worth learning that'll be helpful with your solo projects as well as if you end up working with other developers at your current job or your next one.
在任何情况下,这都是非常值得学习的东西,它对您的个人项目以及您最终在当前工作或下一份工作中与其他开发人员一起工作都有帮助。
Good luck!
祝你好运!
回答by nzpcmad
回答by Luis Melgratti
I use Gitfor PHP development.
我使用Git进行 PHP 开发。
It's fast, flexible, reliable, clean (CVS and SVN create a lot of hidden folders that I personally don't like).
它快速、灵活、可靠、干净(CVS 和 SVN 创建了很多我个人不喜欢的隐藏文件夹)。
Its distributed nature allow to work the way you want (with or without a central repository).
它的分布式特性允许以您想要的方式工作(有或没有中央存储库)。
You can find more about it here:
你可以在这里找到更多关于它的信息:
回答by GloryFish
Versions is working well for another developer I work with. Additionally, if you are using Textmate the SVN bundle provides pretty much all you need for most parts of the Subversion workflow. I really like it.
Versions 对我合作的另一位开发人员运行良好。此外,如果您使用 Textmate,则 SVN 捆绑包提供了几乎所有 Subversion 工作流程所需的内容。我很喜欢。
The Project Plusplugin takes it a step further by adding small unobtrusive badges to versioned files in the project tree, showing at a glance the state of files in a project.
该项目外加插件,它需要通过添加少量不显眼的徽章版本的文件在工程树,显示一目了然文件的状态项目中的一步。
回答by Ian P
Moreover, you can get the Eclipse PDT (PHP Plugin) and use Subclibse in the IDE.
此外,您可以获取 Eclipse PDT(PHP 插件)并在 IDE 中使用 Subclibse。
回答by JRomio
use bazaar http://bazaar-vcs.org/
it's very nice and you can start using it in minutes.
它非常好,您可以在几分钟内开始使用它。
回答by typeoneerror
If you're on a Mac, do yourself a favor and pick up Versions, a beautifully designed (and highly functional) Subversion GUI. You'd do best to learn the terminology and get an idea of how Subversion works using a GUI before you jump to the command line. Once you're able to commit revisions of your code and run updates to get other people's work, then go back and read the red bean book (it really is the best way to learn Subversion in-and-out).
如果您使用的是 Mac,请帮自己一个忙并选择 Versions,这是一个设计精美(且功能强大)的 Subversion GUI。在跳转到命令行之前,您最好先学习术语并了解 Subversion 如何使用 GUI 工作。一旦您能够提交代码的修订并运行更新以获取其他人的工作,然后回去阅读红豆书(这确实是深入学习 Subversion 的最佳方式)。
回答by Svet
回答by cdonner
Alex, Version control (and some will scathe me for this statement) is not a trivial matter, and even very experienced developers get themselves into trouble. The most frequent causes for frustration are limitations of a particular product (Visual Source Safe is a famous one), and members of a team not following the same process, or not understanding the process at all. This should not stop you from looking into using a source control tool - the opposite is the case. You can only use a tool effectively if you understand what it does and why.
Alex,版本控制(有些人会因为这句话而责备我)不是一件小事,即使是非常有经验的开发人员也会遇到麻烦。令人沮丧的最常见原因是特定产品的局限性(Visual Source Safe 是著名的产品),以及团队成员没有遵循相同的流程,或者根本不了解流程。这不应阻止您考虑使用源代码控制工具 - 情况恰恰相反。只有了解工具的作用和原因,才能有效地使用工具。
I would recommend that you look into CVS. It has been around for many years, it is relatively simple to install, set up, and use, and while there are GUI clients available for most platforms, learning it from the command line may provide the best access to its features.
我建议您查看 CVS。它已经存在多年,安装、设置和使用相对简单,虽然有适用于大多数平台的 GUI 客户端,但从命令行学习它可能提供对其功能的最佳访问。

