简体   繁体   English

开始使用版本控制

[英]Getting started with Version Control

I need to implement version control, even for just the developing I do at home.我需要实现版本控制,即使只是我在家做的开发。 I have read about how great Subversion is for the past couple years and was about to dedicate myself to learning this on the side until I heard about Git being the up and coming version control system.在过去的几年里,我已经阅读了关于 Subversion 是多么伟大的文章,并且我正准备致力于学习这方面的知识,直到我听说 Git 是即将到来的版本控制系统。

Given the situation, should I hold off and see which one comes out on top?鉴于这种情况,我应该暂缓一下,看看哪一个名列前茅吗? What are their relative advantages?它们的相对优势是什么?

One issue I noticed with Git is there are not many full featured GUIs, which is important to many users on my team.我注意到 Git 的一个问题是没有很多功能齐全的 GUI,这对我团队中的许多用户来说很重要。

Also, wouldn't mind suggestions on how to get started with one or the other.此外,不介意有关如何开始使用其中一个的建议。 (tutorials, etc.) (教程等)

The most important thing about version control is: 版本控制最重要的是:

JUST START USING IT 只是开始使用它

Not using version control is a horrible idea. 不使用版本控制是一个可怕的想法。 If you are not using version control, stop reading right now and start using it. 如果您没有使用版本控制,请立即停止阅读并开始使用它。

It is very easy to convert from 它很容易转换

cvs<->svn<->git<->hg

It doesn't matter which one you choose. 你选择哪一个并不重要。 Just pick the easiest one for you to use and start recording the history of your code. 只需选择最容易使用的一个,然后开始记录代码的历史记录。 You can always migrate to another (D)VCS later. 您可以随后迁移到另一个(D)VCS。

If you are looking for a easy to use GUI look at TortoiseSVN (Windows) and Versions (Mac) (Suggested by codingwithoutcomments ) 如果您正在寻找易于使用的GUI,请查看TortoiseSVN(Windows)版本(Mac) (建议通过编写而不是评论


Edit: 编辑:

pix0r said: pix0r说:

Git has some nice features, but you won't be able to appreciate them unless you've already used something more standard like CVS or Subversion. Git有一些不错的功能,但除非你已经使用过更复杂的标准,比如CVS或Subversion,否则你将无法欣赏它们。

This. 这个。 Using git is pointless if you don't know what version control can do for you. 如果你不知道版本控制可以为你做什么,使用git是没有意义的。

Edit 2: 编辑2:

Just saw this link on reddit: Subversion Cheat Sheet . 刚看到reddit上的这个链接: Subversion Cheat Sheet Good quick reference for the svn command line. svn命令行的快速参考。

Use subversion, it's easy to setup, easy to use, and has plenty of tools. 使用subversion,它易于设置,易于使用,并且有很多工具。 Any future revision system will have an import from SVN feature, so it isn't like you can't change down the road if your needs grow. 任何未来的修订系统都将从SVN功能导入,因此如果您的需求增长,就不会无法改变。

The Subversion Book is your best bet for learning the tool. Subversion Book是学习该工具的最佳选择。 There may be other quick-start tutorials out there, but the Book is the best single reference you'll find. 可能还有其他快速入门教程,但本书是您可以找到的最佳单一参考。

Git has some nice features, but you won't be able to appreciate them unless you've already used something more standard like CVS or Subversion. Git有一些不错的功能,但除非你已经使用过更复杂的标准,比如CVS或Subversion,否则你将无法欣赏它们。 I'd definitely agree with the previous posters and start with Subversion. 我绝对同意以前的海报,并从Subversion开始。

If you are new to versioncontrol read this: 如果您是versioncontrol的新手,请阅读:
Source Control HOWTO 源控制HOWTO

Go for SVN. 去SVN。 If you have never used source control before, it won't matter to you one way or the other. 如果您以前从未使用过源代码控制,那么无论如何都不会对您产生任何影响。

Also, there is not a large amount of learning involved in using a Source Control system. 此外,使用源控制系统不涉及大量学习。 If you learn one, you can easily switch over to another at a later date. 如果您学习了一个,您可以在以后轻松切换到另一个。

SVN is a great tool, and it should take care of most of your needs. SVN是一个很好的工具,它应该满足您的大部分需求。 And since it's been around, it has a fair sharer of GUI tools (TortoiseSVN, for example). 而且由于它已经存在,它有一个公平的GUI工具共享(例如TortoiseSVN)。

Go for SVN. 去SVN。

I've used RCS, CVS, SCCS, SourceSafe, Vault, perforce, subversion, and git. 我使用过RCS,CVS,SCCS,SourceSafe,Vault,perforce,subversion和git。

I've evaluated BitKeeper, Dimensions, arch, bazaar, svk, ClearCase, PVCS, and Synergy. 我评估了BitKeeper,Dimensions,arch,bazaar,svk,ClearCase,PVCS和Synergy。

If I had to start a new repository today, I'd choose git . 如果我今天必须启动一个新的存储库,我会选择git Hands down. 把手放下。

It's free, fast, and under active development. 它是免费的,快速的,并且正在积极开发中。

And you can use it as a client of any subversion repository using git-svn. 您可以使用git-svn将其用作任何subversion存储库的客户端。

It rocks. 它摇滚。

For a friendly explanation of most of the basic concepts, see A Visual Guide to Version Control . 有关大多数基本概念的友好解释,请参阅版本控制的可视指南 The article is very SVN-friendly. 这篇文章非常适合SVN。

@superjoe30 @ superjoe30

What about using source control on your own computer, if you're the sole programmer? 如果您是唯一的程序员,那么在您自己的计算机上使用源代码控制呢? Is this good practice? 这是好习惯吗? Are there related tips or tricks? 有相关的提示或技巧吗?

I find git is actually easier for this as you don't need a server or worry about entering URL's and so on. 我发现git实际上更容易,因为你不需要服务器或担心输入URL等等。 Your version-control stuff just lives in the .git directory inside your project and you just go ahead and use it. 您的版本控制内容只存在于项目内的.git目录中,您只需继续使用它即可。

5 second intro (assuming you have installed it) 5秒介绍(假设您已安装)

cd myproject
git init
git add * # add all the files
git commit

Next time you do some changes 下次你做一些改变

git add newfile1 newfile2 # if you've made any new files since last time
git commit -a

As long as you're doing that, git has your back. 只要你这样做,git就会退缩。 If you mess up, your code is safe in the nice git repository. 如果你陷入困境,你的代码在nice git存储库中是安全的。 It's awesome 这很棒

  • Note: You may find getting things OUT of git a bit harder than getting them in, but it's far more preferable to have that problem than to not have the files at all! 注意:你可能会发现使用它们比使用它们要困难得多,但是这个问题远比没有文件要好得多!

From my own experience with it, I wouldn't recommend git as an introduction to version control. 根据我自己的经验,我不会推荐git作为版本控制的介绍。 I've been using it for a couple of months now, and my impression is that it's very powerful and - now that I've partially got my head around it - reasonably intuitive. 我已经使用它几个月了,而且我的印象是它非常强大 - 现在我已经部分了解它 - 相当直观。 However, the learning curve is very steep, even though I've been using version control for years. 然而,即使我多年来一直使用版本控制,学习曲线也非常陡峭。 It also suffers from being too expressive - it supports many different workflows and development models, but the only guidance on "the best" way to use it is a few pages deep in a Google search, which also makes it tricky for a newcomer to pick up. 它也有过于富有表现力 - 它支持许多不同的工作流程和开发模型,但是对于“最佳”使用方式的唯一指导是谷歌搜索的几页深度,这也使新手选择变得棘手起来。

That said, it's possible that starting from a blank slate with git might actually be easier - my VCS experience is all with centralised version control (CVS, SVN, Perforce...) and part of my (ongoing!) difficulty with git has been understanding the implications of the distributed model. 也就是说,从带有git的空白平板开始可能实际上更容易 - 我的VCS体验全部采用集中式版本控制(CVS,SVN,Perforce ......),部分我(正在进行!)的git困难已经存在理解分布式模型的含义。 I did glance briefly at other DVCSes like Bazaar and Mercurial and they seemed to be somewhat more newbie-friendly. 我简单地看了一下像Bazaar和Mercurial这样的其他DVCS,他们似乎对新手友好了。

Anyway, as others have said, Subversion is probably the easiest way to get used to the version control mindset and get practical experience of the benefits of VCS (rollback, branches, collaborative development, easier code review, etc). 无论如何,正如其他人所说,Subversion可能是习惯版本控制思维模式的最简单方法,并且可以获得VCS优势的实际体验(回滚,分支,协作开发,更轻松的代码审查等)。

Oh, and don't start with CVS. 哦,不要从CVS开始。 It's still in practical use, and has advantages, but IMHO it has too many historical quirks and implementation problems (non-atomic commits!) to be a good way to learn. 它仍然在实际使用中,并且具有优势,但恕我直言,它有太多的历史怪癖和实现问题(非原子提交!)是一个很好的学习方法。

My vote goes to Subversion. 我的投票是Subversion。 It's very powerful, yet easy to use, and has some great tools like TortoiseSVN . 它非常强大,但易于使用,并且有一些很棒的工具,比如TortoiseSVN

But as others have said before me, JUST START USING IT. 但正如其他人在我之前所说,只是开始使用它。 Source control is such an important part of the software development process. 源代码控制是软件开发过程中非常重要的一部分。 No "serious" software project should be without it. 没有“严肃”的软件项目应该没有它。

At my current job, my predecessor did not use any kind of version control. 在我目前的工作中,我的前任没有使用任何类型的版本控制。 There are just mountains of folders in at least 3 different places where he kept all of his projects. 在至少3个不同的地方只有大量的文件夹,他保留了所有的项目。 Any random project folder can be expected to find at least one folder name "project (OLD)" and one named "project" 任何随机项目文件夹都可以找到至少一个文件夹名称“project(OLD)”和一个名为“project”的文件夹

With version control, you never have to make copies of "safe" builds. 使用版本控制,您永远不必复制“安全”版本。 You don't really have to worry about your IDE corrupting the file you're working on (I'm looking at you, REALBasic 5.5) because is so easy to commit (Read: Save) your work every day. 你真的不必担心你的IDE会破坏你正在处理的文件(我正在看你,REALBasic 5.5)因为你每天都很容易提交(阅读:保存)你的工作。

Needless to say, I installed version control the day after I found out it existed. 不用说,我发现它存在后的第二天就安装了版本控件。

Also, TortoiseSVN makes committing to the database as easy as right clicking a folder. 此外,TortoiseSVN使得提交到数据库就像右键单击文件夹一样简单。

如果要避免任何命令行工作,还要为服务器尝试visual svn

Git is superior to subversion, but it's a little bit out on the bleeding edge. Git优于颠覆,但它在前沿有点偏执。

I'd say, if you're just getting started, jump on the edge; 我会说,如果你刚刚开始,就跳到边缘; setup a free account @ http://github.com 设置免费帐户@ http://github.com

They have educational material on site for setting up & using git. 他们在现场有教育材料来设置和使用git。

如果您使用的是Mac OSX,我发现http://www.versionsapp.com/">版本是SVN令人难以置信的(免费)GUI前端。

Don't wait. 不要等 Pick one, and go with it. 选一个,然后去吧。 All systems will have their pluses and minuses. 所有系统都有其优点和缺点。 Your power could go out, you computer gets stolen, or you forget to undo a major change and all your code gets fried while you're waiting to see who emerges victorious. 你的力量可能会消失,你的计算机被盗,或者你忘了撤消一个重大的改变而你所有的代码都会被炒掉,而你正等着看谁胜出来了。

SubVersion is the best Choice for you , As Karl Seguin pointed out Moving to Another Versioning System would not be a problem. SubVersion是您的最佳选择,正如Karl Seguin所指出的那样转移到另一个版本控制系统不会有问题。 also SVN has very goof Easy to use GUIs in the Client Side (TortoiseSVN). SVN也很容易在客户端使用易于使用的GUI(TortoiseSVN)。

http://www.snee.com/bobdc.blog/2007/08/getting_started_with_subversio.html http://dojo.jot.com/WikiHome/Getting%20Started%20With%20Subversion http://www.snee.com/bobdc.blog/2007/08/getting_started_with_subversio.html http://dojo.jot.com/WikiHome/Getting%20Started%20With%20Subversion

If you choose to go with subversion and you want to host your own svn server, then there is a very nice and easy windows based server called VisualSVN server. 如果您选择使用subversion并且想要托管自己的svn服务器,那么有一个非常好的,简单的基于Windows的服务器,称为VisualSVN服务器。 It hides the complexity of setting up an apache server, you basically just go next next next. 它隐藏了设置apache服务器的复杂性,你基本上只需要下一步。 User configuration is handled with a webUI, instead of a config 用户配置使用webUI而不是配置进行处理

http://www.visualsvn.com/server/ http://www.visualsvn.com/server/

using a public serve rlike beanstalk is probably easier, but some people like to have their own repositories, either for speed or security 使用公共服务rlike beanstalk可能更容易,但有些人喜欢拥有自己的存储库,无论是速度还是安全性

Use TortoiseSVN (version.app if on mac). 使用TortoiseSVN(如果在mac上,则为version.app)。 Just install and go. 只需安装即可。 If you need a place to host your code look at http://beanstalkapp.com/ 如果您需要一个托管代码的地方,请访问http://beanstalkapp.com/

Coding Horror has a great post abouthow to set up Subversion on Windows . Coding Horror 有一篇关于如何在 Windows 上设置 Subversion的精彩帖子。

Following the tutorial, I was able to get Subervsion and TortoiseSVN running locally, and I got the education I needed out of it.按照教程,我能够在本地运行 Subervsion 和 TortoiseSVN,并从中获得所需的教育。

As far as Git goes, it's probably a good idea to do a hands on experiment with both of them, to understand which fits your specific development practice.就 Git 而言,对它们进行动手实验可能是一个好主意,以了解哪个适合您的特定开发实践。

It's not that difficult to switch between version control systems. 在版本控制系统之间切换并不困难。 As others have mentioned the important thing is to start using anything as soon as possible. 正如其他人所说,重要的是尽快开始使用任何东西。 The benefits of using source control over not using source control vastly outweigh the differential benefits between different types of source control. 使用源代码控制而不是使用源代码控制的好处大大超过了不同类型的源代码控制之间的差异优势。

Remember that no matter what version of source control you are using you will always be able to do a brute force conversion to another system by laying down the files from your old system onto disk and then importing those raw files into the new system. 请记住,无论您使用何种版本的源代码控制,您都可以通过将旧系统中的文件放入磁盘,然后将这些原始文件导入新系统,从而强制转换到另一个系统。

Moreover, being familiar with source control fundamentals is a very, very important skill to have as a software developer. 此外,熟悉源代码控制基础知识是软件开发人员非常非常重要的技能。

I would definitely choose SVN over CVS, if only because people who learned source control using CVS, tend to use " svn delete " then " svn add " instead of " svn move ". 我肯定会选择SVN而不是CVS,只是因为使用CVS学习源代码控制的人倾向于使用“ svn delete ”然后使用“ svn add ”而不是“ svn move ”。 Which makes it harder to find all of the previous revisions of a specific file. 这使得查找特定文件的所有先前版本变得更加困难。 And you can always upgrade to using git-svn. 您可以随时升级到使用git-svn。 I personally think it is easier to learn than hg, but really the main reason to use SVN is it has largely become the de-facto version control system of Open Source Software. 我个人认为这是更容易学习比HG,但真正使用SVN是它已在很大程度上成为开源软件的事实上的版本控制系统的主要原因

If you ever plan on learning / using D it is almost mandatory to access the third party repositories, like DSource . 如果您计划学习/使用D ,则几乎必须访问第三方存储库,如DSource

@superjoe30 Yes, absoluteley. @ superjoe30是的,绝对的。 Once you start using version control you never go back. 一旦你开始使用版本控制,你永远不会回去。 I use it for everything, even my "home" folder. 我把它用于一切,甚至我的“家”文件夹。

@Orion Edwards Subversion does not require a server. @Orion Edwards Subversion不需要服务器。 You can access a local repository directly (via a client, of course), and there is no server process involved. 您可以直接访问本地存储库(当然是通过客户端),并且不涉及服务器进程。

Just use TortoiseSVN, and you can live even without knowing actual Subversion commands... But that's bad. 只要使用TortoiseSVN,你甚至可以在不知道实际的Subversion命令的情况下生活......但这很糟糕。 Luckily there will always be a “great opportunity” to learn them by heart — when your priceless repository first gets corrupted. 幸运的是,当你无价的存储库首次被破坏时,总会有一个“很好的机会”来学习它们。

Yes, it happens. 是的,它发生了。

As mentioned many times elsewhere, Just Do It. 正如其他地方多次提到的,Just Do It。 I was able to get started from scratch with Subversion under Windows in no time by reading the quick-start guide in the Red Book. 通过阅读红皮书中的快速入门指南,我可以在Windows下从头开始使用Subversion。 Once I pointed TortoiseSVN at the repository, I was in business. 一旦我将TortoiseSVN指向存储库,我就开始了。 It took me a while to get the finer points down, but they were minor humps to get over. 我花了一段时间才得到更好的分数,但是他们只是轻微的驼峰才能克服。

I'd suggest installing the Subversion Service instead of using file:// URLs, but that's mostly personal preference. 我建议安装Subversion服务而不是使用file:// URL,但这主要是个人偏好。 For a repository stored on your development machine, file:// works fine. 对于存储在开发计算机上的存储库,file://工作正常。

From personal experience, svn would be my recommendation. 从个人经验来看,svn将是我的推荐。 You can even use a service like Beanstalk that offers free accounts (with limits obviously, but sufficient for any smallish project) to test the waters. 您甚至可以使用像Beanstalk这样的服务来提供免费帐户(显然有限制,但对于任何小型项目都足够)来测试水域。 But as others have said, git is superior and is likely worth looking into. 但正如其他人所说,git是优越的,可能值得研究。

When I decided I must use a code versioning system, I looked around for any good tutorials on how to get started but didn't find any that could help me. 当我决定使用代码版本控制系统时,我四处寻找有关如何入门的任何好教程,但没有找到任何可以帮助我的内容。

So I simplely installed the SVN Server and Tortoise SVN for the client and dived into the deepend and i learn't how to use it along the way. 所以我简单地为客户端安装了SVN服务器和Tortoise SVN并潜入了深度,我不知道如何使用它。

Start using SVN for your actual work, but try to make time for fiddling around with Git and/or Mercurial. 开始使用SVN进行实际工作,但尝试花点时间摆弄Git和/或Mercurial。 SVN is reasonably stable for production, but eventually you'll face a scenario where you'll need a distributed SCM, by which time you'll be properly armed and the new systems will be mature enough. SVN在生产方面相当稳定,但最终你将面临一个需要分布式SCM的场景,届时你将得到适当的武装,新系统将足够成熟。

Yup, SVN for preference unless you really need git's particular features. 是的,SVN是首选,除非你真的需要git的特殊功能。 SVN is hard enough; SVN很难; It sounds like git is more complicated to live with. 这听起来像git更复杂。 You can get hosted svn from people like Beanstalk - unless you have in-house Linux people, I'd really recommend it. 你可以从像Beanstalk这样的人那里获得托管的svn - 除非你有内部Linux人员,我真的推荐它。 Things can go wrong horribly easily and it's nice to have someone else whose job it is to fix it. 事情可能很容易出错,让别人找工作就好了。

There's an excellent tutorial on revision control from Eric Sink which is worth reading no matter which system you use. Eric Sink提供了一个关于版本控制的优秀教程 ,无论您使用哪种系统,都值得一读。

superjoe30 writes : superjoe30写道

Related question (perhaps answers can be edited to answer this question as well): 相关问题(也许可以编辑答案来回答这个问题):

What about using source control on your own computer, if you're the sole programmer? 如果您是唯一的程序员,那么在您自己的计算机上使用源代码控制呢? Is >>this good practice? 是>>这个好习惯吗? Are there related tips or tricks? 有相关的提示或技巧吗?

I use SVN for all of my personal projects. 我将SVN用于我的所有个人项目。 I started off with running svn on my home machine but eventually migrated over to Dreamhost. 我开始在家用机器上运行svn但最终迁移到Dreamhost。 Their hosting packages that include Subversion are pretty reasonable. 他们的托管包包括Subversion是非常合理的。

One major tip to ease the setup of an SVN server right now is to use a Virtual Appliance. 现在简化SVN服务器设置的一个主要技巧是使用虚拟设备。 That is, a virtual machine that has subversion pre-installed and (mostly) pre-configured on it - pretty much a plug & play thing. 也就是说,预先安装了subversion并且(大部分)预先配置了subversion的虚拟机 - 几乎就是即插即用的东西。 You can try here , here and here , or just try searching Google on "subversion virtual appliance". 你可以在这里这里这里试试,或者只是尝试在Google上搜索“颠覆虚拟设备”。

I started to use subversion after reading Wil Shipleys blog.在阅读了 Wil Shipleys 的博客后,我开始使用 subversion。

So I started checking in code, one machine and dreamhost account.所以我开始检查代码,一台机器和dreamhost帐户。 Then after I accidentally deleted a function and saved my project I knew I was in deep "dudu", but with subversion I just checked out the latest version of that file and it was like nothing happened.然后,在我不小心删除了一个函数并保存了我的项目之后,我知道我陷入了“dudu”的深渊,但是使用 subversion 我刚刚检查了该文件的最新版本,就像什么也没发生一样。

I use version control for everything now.我现在对一切都使用版本控制。 I am planning on moving over to git because it is faster, works offline, takes less space and oh boy is it faster.我打算转移到 git,因为它更快,离线工作,占用更少的空间,哦,天哪,它更快。

An important reason to use svn rather than cvs is svn supports binary diffs.使用 svn 而不是 cvs 的一个重要原因是 svn 支持二进制差异。 That may not matter to many programmers but if you are making a series of minor changes in a 10Mb image, having a unique copy each time in your repository can chew up space remarkably quickly.这对许多程序员来说可能无关紧要,但如果您要对 10Mb 的图像进行一系列微小的更改,则每次在您的存储库中都有一个唯一的副本会非常快地占用空间。

I use TortoiseSVN on Windows but on the Mac have gone for the commercial CornerStone client over the (now commercial) Versions client.我在 Windows 上使用 TortoiseSVN,但在 Mac 上已经通过(现在商业)版本客户端使用商业CornerStone客户端。 I found the range of free Mac clients, including RapidSVN, had enough pain points to bug me into shelling out real dollars.我发现包括 RapidSVN 在内的一系列免费 Mac 客户端有足够的痛点让我掏出真正的美元。 The safety-net that CornerStone provides for catching files I forgot to add to repository is worth the dollars to me. CornerStone 提供的用于捕获我忘记添加到存储库的文件的安全网对我来说物有所值。 I spend a lot of time collaborating with a US client who is in an opposite time zone so can't afford screwups forgetting to add files!我花了很多时间与位于相反时区的美国客户合作,因此无法承受忘记添加文件的错误!

If on a windows box a quick and dirty slution is CVSNT. 如果在窗户盒子上快速而肮脏的洗脱是CVSNT。 Easy to use just set it up and works very well. 易于使用只需设置它并且工作得很好。

I myself prefer SVN but this is a good one for quick use. 我自己更喜欢SVN,但这是一个很好的快速使用。

Short answer: Subversion if you're the only one coding it or you're on site with everyone you work with.简短回答:Subversion 如果你是唯一一个编码它的人,或者你和你一起工作的每个人都在现场。 GIT if you're working with people in different sites and your code base is huge.如果您与不同站点的人一起工作并且您的代码库很大,请使用 GIT。

Subversion is really, really easy to setup and get using. Subversion 非常非常容易设置和使用。 It is also nice because you can do relatively complicated things with it too, like hook it up to Apache and use SSL or plug it into Trac for project management.它也很好,因为你也可以用它做相对复杂的事情,比如将它连接到 Apache 并使用 SSL 或将它插入 Trac 进行项目管理。 There's so many tools available for Subversion that it's really a good choice. Subversion 有很多可用的工具,它确实是一个不错的选择。

GIT is much more useful for people who are on large teams working in a distributed environment. GIT 对于在分布式环境中工作的大型团队的人来说更有用。 Linus T. developed it for the Linux team because he was unsatisfied with the capabilities of traditional repositories. Linus T. 为 Linux 团队开发了它,因为他对传统存储库的功能不满意。 Well worth learning if you ever plan to be working with people on open source projects.如果您打算与开源项目的人一起工作,那么非常值得学习。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM