简体   繁体   English

对于单个开发人员来说,是否值得从SVN转到Git?

[英]Is it worth going to Git from SVN for a single developer?

--- THIS THREAD IS VERY LIKELY OUTDATED AS OF 2013 --- ---这条线在2013年非常糟糕---

Is it worth going to GIT from SVN when the repositories are mainly accessed by a single developer? 当存储库主要由单个开发人员访问时,是否值得从SVN转到GIT? I have several machines that I use for development and not mainly develop in C#. 我有几台机器用于开发,而不是主要用C#开发。 But I have a mix of VB, VB.Net, PHP, C#, C++, HTML, Batch, BASH and many more in my repositories. 但我在我的存储库中混合使用VB,VB.Net,PHP,C#,C ++,HTML,Batch,BASH等等。 What, if anything, will I gain by migrating to GIT from SVN? 通过从SVN迁移到GIT,我将获得什么? Right now use TortoiseSVN + VisualSVN Server with a set of central repositories and several client machines. 现在使用TortoiseSVN + VisualSVN Server与一组中央存储库和几个客户端机器。 While I have granted a few friends access to my repositories they do not Update or Commit often (if ever). 虽然我已授予一些朋友访问我的存储库的权限,但他们并不经常更新或提交(如果有的话)。

Also is there a way to have the flexibility and ease of maintenance I get with VisualSVN Server + TortiseSVN with Git? 还有一种方法可以使用VisualSVN Server + TortiseSVN和Git获得灵活性和易维护性吗?

((I'll bite... what other platforms and trickery would be compelling for a single developer/small group?) ((我会咬一口......对于一个开发者/小组来说,其他平台和技巧会引人注目吗?)

Please List Pros and Cons not just one sided opinions. 请列出优点和缺点,而不仅仅是单方面的意见。

Current Tool Chain... Visual Studio 2008 (C#/VB.Net) + TortoiseSVN + VisualSVN 当前工具链... Visual Studio 2008(C#/ VB.Net)+ TortoiseSVN + VisualSVN

Main Focus... XNA Games, WCF/Socket Services, Web Development 主要焦点... XNA游戏,WCF /套接字服务,Web开发

I can give you three advantages: 我可以给你三个好处:

  1. You can have multiple back up repositories. 您可以拥有多个备份存储库。 Git isn't centralised, so you can keep your repo on whatever machine you're working on and push changes to any back up locations you have. Git不是集中式的,因此您可以将您的仓库保留在您正在处理的任何计算机上,并将更改推送到您拥有的任何备份位置。 I keep my repos on github , and two other locations. 我把我的回购保留在github和其他两个地方。
  2. Branching, merging, rebasing, amending commits, git bisect. 分支,合并,重新定位,修改提交,git bisect。 Just because you are a single dev, there is no reason not to use the best tools. 仅仅因为你是一个单独的开发者,没有理由不使用最好的工具。
  3. git-svn - you can give it a try in parallel with your subversion repos while you make your mind up. git-svn - 你可以尝试与你的subversion repos并行尝试,同时你会想出来。

There is a disadvantage; 有一个缺点; and that is that the visualisation tools available on Windows are not as user friendly as those that are, perhaps, available for other platforms. 这就是Windows上可用的可视化工具不像那些可能用于其他平台的用户友好。

Yes, of course. 当然是。

You're misunderstanding what git is. 你误解了git是什么。 I mean, why would you assume it's only useful for teams? 我的意思是,你为什么认为它只对团队有用?

git is even more worth it if you're a single developer. 如果你是一个开发人员,git更值得。

Pros: 优点:

  • svn requires a server to run in the background. svn要求服务器在后台运行。 git on the other hand, is a simple utility, you just run it as if you're running grep or ls or any other simple command line utility. 另一方面,git是一个简单的实用程序,只需运行它就像运行grepls或任何其他简单的命令行实用程序一样。 You don't need to setup any server or anything like that. 您不需要设置任何服务器或类似的东西。
  • The .git folder is the entire repository, you can take it with you anywhere (for example, on a USB stick) and it will always have your repo. .git文件夹是整个存储库,您可以随身携带(例如,在USB记忆棒上),它将始终拥有您的存储库。 Your entire repo, along with its history, and everything else, and it's actually compressed very well, so it doesn't take that much of space. 你的整个回购,以及它的历史,以及其他一切,它实际上压缩得很好,所以它不占用太多空间。 (Hint: that's why git doesn't need a server; when you run git commands, git just changes the internals of the .git folder). (提示:这就是为什么git不需要服务器;当你运行git命令时,git只是改变了.git文件夹的内部)。
  • Branching and merging is really easy. 分支和合并非常简单。 You can work on experimental new features on a separate branch, and only merge when its stabilized. 您可以在单独的分支上处理实验性新功能,并且只有在其稳定时才合并。 Meanwhile, you can do maintenance work on the master branch (eg bug fixes) and all the while you can keep merging the bug fixes from the master branch into your experimental (topic) branch with ease. 同时,您可以在主分支上进行维护工作(例如,错误修复),同时您可以轻松地将主分支中的错误修复程序合并到您的实验(主题)分支中。
  • This point is subjective, but I find it much easier than svn. 这一点是主观的,但我觉得它比svn容易得多。 I tried to use svn for a while, but found it too complicated, and often it got in my way (I don't exactly remember that what's and why's, I just know it wasn't a pleasant experience). 我尝试使用svn一段时间,但发现它太复杂了,而且常常妨碍我(我不记得那是什么和为什么,我只知道这不是一个愉快的经历)。 For example, renaming files is not an issue. 例如,重命名文件不是问题。 You can rename files and git won't make any fuss, it just doesn't care about the file name. 你可以重命名文件和git不会做任何大惊小怪,它只是不关心文件名。 The only thing is, you have to remember to add it after you rename it, it's as if you created a new file. 唯一的事情是,你必须记住在重命名后添加它,就好像你创建了一个新文件。

Cons: 缺点:

  • Not many visual tools. 没有多少视觉工具。 There's a git-gui, it's not bad, (I haven't used it much) but you don't wanna depend on it. 有一个git-gui,它还不错,(我没有太多使用它),但你不想依赖它。 You need to get used to using it from the command line. 您需要习惯从命令行使用它。 If you're used to visual tools with svn, this maybe a con, but in my opinion, the only con here is that you have to step a little bit out of your comfort zone to learn it; 如果你已经习惯了使用svn的视觉工具,这可能是一个骗局,但在我看来,这里唯一的问题是你必须稍稍离开你的舒适区才能学习它; but trust me it's worth it. 但请相信我,这是值得的。
  • There maybe some issues with line-ending on windows, it's not a big problem if you're the only developer, but if you're developing on windows and others are developing on linux, you need to make sure that all files use unix-style line ending instead of windows', in order to avoid any issues. 在Windows上可能存在一些关于行结尾的问题,如果你是唯一的开发人员,这不是一个大问题,但如果你是在windows上开发而其他人在linux上开发,你需要确保所有文件都使用unix-样式行结束而不是windows',以避免任何问题。
  • Due to lack of visual tools, resolving conflicts (when they appear) might be trouble some at first. 由于缺乏可视化工具,解决冲突(当它们出现时)起初可能会有些麻烦。 I personally use WinMerge, and invoke the command winmergeu <conflictfile> on every conflict file, to resolve conflicts. 我个人使用WinMerge,并在每个冲突文件上调用命令winmergeu <conflictfile>来解决冲突。 (Note: WinMerge is not a command-line merge tool, it's a visual merge tool, with a normal gui). (注意:WinMerge不是命令行合并工具,它是一个可视化的合并工具,具有正常的gui)。
  • This brings me to another point. 这让我想到了另一点。 While it's really easy to get started with git, there maybe some learning curve to dealing with issues that come up later (such as conflict resolution). 虽然开始使用git非常容易,但是处理稍后出现的问题(例如解决冲突)可能会有一些学习曲线。 If you don't branch and merge, then you won't even run into conflicts, but then again you'll also be missing a very powerful feature. 如果你不进行分支和合并,那么你甚至不会遇到冲突,但是你也会失去一个非常强大的功能。

UPDATE: 更新:

I didn't notice the bit about you working from several different machines. 我没注意到你在几台不同的机器上工作。

It doesn't make a difference, you just have to remember to push and pull whenever you switch to a different machine, but you already do this with svn: commit/update. 它没有什么区别,只要你切换到另一台机器就必须记住推拉,但你已经用svn:commit / update做了这个。

You'll get the power of branching/merging. 你将获得分支/合并的力量。 Don't under-estimate this power. 不要低估这种力量。

How many times have you thought of implementing some crazy idea, but never dared to do it because you don't want to mess up your code? 你有多少次想过实现一些疯狂的想法,但从来不敢这么做因为你不想弄乱你的代码? git relieves you from these worries. git让你免于这些烦恼。 Just do it in a branch, if it works out, merge it to the main branch, if it didn't, delete the branch and forget about it. 只是在分支中执行它,如果它运行,将它合并到主分支,如果没有,删除分支并忘记它。

Sure, you might say that you can do the same with svn revert , reverting back to the revision before you started the crazy idea. 当然,你可能会说你可以用svn revert做同样的事情,在你开始疯狂的想法之前恢复到修订版。 but what if you had bug fixes applied in the meantime? 但是,如果你同时修复了错误修复怎么办? If you revert your crazy idea, you'll lose all the bug fixes/maintenance work you did while experimenting with your crazy idea. 如果你恢复了疯狂的想法,你将失去在尝试疯狂想法时所做的所有错误修复/维护工作。

Apart from what has already been said, If you're a single developer and haven't experienced troubles with SVN I see no reason to switch. 除了已经说过的话,如果你是一个单一的开发人员并且没有遇到过SVN的麻烦,我认为没有理由转换。 svnserve (the daemon) works fine locally (I have OS X). svnserve(守护进程)在本地工作正常(我有OS X)。

TortoiseSVN is a blessing compared to Git tools… is there any particular reason why you'd like to move away from Subversion? 与Git工具相比,TortoiseSVN是一种祝福......你有什么特别的理由想要摆脱Subversion吗?

It really depends on your workflow. 这实际上取决于您的工作流程。 Do you work often from places where you cannot reach your svn server? 你经常在无法到达svn服务器的地方工作吗? Do your projects have a large number of branches because you like working on several (big) things at the same time? 你的项目是否有大量的分支,因为你喜欢同时处理几个(大)的事情? Do you copy working copies between machines? 你在机器之间复制工作副本吗? Do you split off new branches from an existing branch? 你是否从现有的分支机构中拆分了新的分支机构? Do you sometimes work on the trunk and halfway through a bunch of changes think "I should have done this in a branch"? 你有时在后备箱上工作,在一堆变化的中途想到“我应该在一个分支中做到这一点”吗? If so, then it may be useful. 如果是这样,那么它可能是有用的。

From a single developer's point of view, the main difference between a central system like svn and a decentral system like git is that in svn the revisions are linear. 从单一开发人员的角度来看,像svn这样的中央系统和像git这样的分散系统之间的主要区别在于,在svn中,修订是线性的。 With git it's a tree. 用git它是一棵树。 This is useful when you work on bigger features that you want to do in multiple commits. 当您处理要在多次提交中执行的更大功能时,这非常有用。

Example: You have a big feature F that consists of changes a, b, c and d. 示例:您有一个很大的功能F,它包含更改a,b,c和d。 With Subversion you'd either commit a, b, c and d separately on the trunk, or you'd create a branch which means you have to do a lot of merging. 使用Subversion,您可以在主干上单独提交a,b,c和d,或者您创建一个分支,这意味着您必须进行大量合并。 With git you check out a working copy, commit a, b, c, and d on it. 使用git,您可以查看工作副本,提交a,b,c和d。 Then you'd push that as a single change F to your master. 然后你将它作为单个更改F推送给你的主人。 So, instead of four commits you see just one commit on the trunk. 因此,您只需在主干上看到一次提交,而不是四次提交。 This makes it easier to see from the log what is going on. 这样可以更容易地从日志中看到发生了什么。

You could do this with svn branches as well. 您也可以使用svn分支执行此操作。 But now suppose that part a also consists of multiple parts, like a1 and a2. 但现在假设a部分也包含多个部分,如a1和a2。

Such a development model can be done with Subversion. 这种开发模型可以使用Subversion完成。 Python Twisted is done that way for example. 例如,Python Twisted以这种方式完成。 All development is done on branches and nobody works on the trunk. 所有的开发都是在分支上进行的,没有人在主干上工作。 But git makes such a workflow easier. 但是git使这样的工作流更容易。

I have used these systems in the manner which you describe, under Windows with Visual Studio 2008: 我在Windows下使用Visual Studio 2008以您描述的方式使用这些系统:

  • Visual Source Safe 视觉源安全
  • Subversion 颠覆
  • Mercurial 水银
  • Git 混帐

If you value your life, do not ever use Visual Source Safe... 如果你珍惜你的生命, 永远 不要使用Visual Source Safe中...

Subversion 颠覆

  • Pros: Excellent tools, both on the server and client side. 优点:优秀的工具,无论是在服务器端还是客户端。 VisualSVN and TortoiseSVN . VisualSVNTortoiseSVN
  • Cons: It doesn't handle merging things too well. 缺点:它不能很好地处理合并的事情。

Git 混帐

  • Pros: Excellent merging support, fast. 优点:优秀的合并支持,快速。
  • Cons: Windows tools are almost non-existent, the GUI ones that do exist are so horrible, I hope I don't ever have to use them again. 缺点:Windows工具几乎不存在,存在的GUI工具非常可怕,我希望我不必再使用它们。 (my opinion) (我的意见)

Mercurial 水银

  • Pros: Excellent merging support, decent tools. 优点:优秀的合并支持,体面的工具。 TortoiseHG and VisualHG , Python based - hook scripts can be written in Python, hooking directly into the HG api. TortoiseHGVisualHG ,基于Python的钩子脚本可以用Python编写,直接挂钩到HG api。
  • Cons: Tools are not up to the same par as with SVN. 缺点:工具与SVN不同。

One thing that may be compelling about Git is that you can continue to work and do commits offline. 关于Git可能引人注目的一件事是你可以继续工作并做离线提交。 So, when you are on the plane, bring your laptop and commit as usual. 所以,当你在飞机上时,带上你的笔记本电脑并照常提交。 When you are back online, you can push back to your main repo. 当您重新上线时,您可以回到主仓库。

If you find you do a lot of branching you will probably prefer Git, as it is designed around making branching/merging easy and commonplace. 如果你发现你做了很多分支,你可能会更喜欢Git,因为它的设计是为了使分支/合并变得简单和普通。

Update: Note you can test out Git without committing to it, since Git can talk to SVN repos . 更新:注意你可以测试出Git而不需要它,因为Git可以与SVN repos交谈 So give it a try, and if you don't like it, nothing lost! 试试吧,如果你不喜欢它,什么都不会丢失!

Just try it, install msysgit , then 试试吧,然后安装msysgit

git svn clone svn://mysvn/repo/

Some of the resources in Git for beginners: The definitive practical guide should be of help ( Gitcasts and Git Magic especially) Git中的一些初学者资源:明确的实用指南应该有所帮助(特别是GitcastsGit Magic

Personally I find git much more pleasant to use in general. 就个人而言,我发现一般来说使用git更加愉快。 I switched my personal SVN repos to git about two years ago and haven't had a single problem with it ever 大约两年前,我将我的个人SVN回购转换为git,并且从来没有遇到任何问题

Not having to worry about your SVN server is nice (no need for constant network access to it), so is being able to trivially create repositories (they're just a folder containing another .git folder), perform any operations (commit, branching etc etc), then decide to put the code on Github with a simple command or two. 不必担心你的SVN服务器很好(不需要对它进行持续的网络访问),因此能够轻松创建存储库(它们只是一个包含另一个.git文件夹的文件夹),执行任何操作(提交,分支)等等,然后决定用一两个简单的命令将代码放在Github上。

It's generally much "snappier" (almost every action basically instant), everything works "offline", clones are complete backups.. but the main reason I keep using it is Github 它通常很“快”(几乎所有动作基本上都是即时的),一切都可以“离线”,克隆是完整的备份..但我继续使用它的主要原因是Github

No. At least not for me. 不,至少不适合我。 What's the point of having a non-centralized repo for a single dev? 为单个开发者提供非集中式回购有什么意义?

Also, the Git Windows tools aren't quite up to the TortoiseSVN bar. 此外,Git Windows工具并不完全取决于TortoiseSVN吧。

Some time ago I did that move from svn to Git. 前段时间我从svn转到Git。 I agree with several of the above answers about advantages of Git distributed architecture over svn (like ability to take my repo with me on my notepad), but the compelling reasons were much more mundane. 我同意上面几个关于Git分布式架构优于svn的优点的答案(比如能够在我的记事本上带我的回购),但令人信服的理由更为平凡。

  • Svn is quite cumbersome, it puts his things (.svn folders) everywhere. Svn非常麻烦,它把他的东西(.svn文件夹)放在各处。 That makes hard to use common command line tools like grep (and many others) on .svn repositories. 这使得很难在.svn存储库上使用常见的命令行工具,如grep(和许多其他命令行)。 In my project I also had some installation procedure that needed to copy a full ressource tree to some system path. 在我的项目中,我还有一些安装过程需要将完整的资源树复制到某个系统路径。 When using svn I had to write extra code (or export repository), just to avoid that my installation procedure also copy .svn. 使用svn时我必须编写额外的代码(或导出存储库),以避免我的安装过程也复制.svn。 That kind of problems totally disappeard using Git. 使用Git,这种问题完全消失了。 All is in one .git directory at root of repository. All位于存储库根目录下的一个 .git目录中。

Nowadays (2/2013) there is only a single .svn folder in root folder present! 如今(2013年2月)根文件夹中只有一个.svn文件夹!

  • I had several bad experience with my svn client on Linux, seemingly simple actions like moving a file and then modifying it before committing caused system hangup using 100% CPU! 我在Linux上的svn客户端遇到了一些不好的经历,看似简单的操作,如移动文件然后在使用100%CPU提交系统挂起之前修改它! (And no, it was not something else that caused the crash and I could repeat it at will). (不,它不是导致崩溃的其他因素,我可以随意重复它)。 Never encountered such problems with Git tools. 从未遇到过Git工具的这些问题。

  • I also had some terrible times merging code between trunk and stable branch on my old svn repository. 我在旧的svn存储库中的trunk和stable分支之间合并代码也有一些糟糕的时间。 It's really easier with Git. 使用Git真的很容易。

Now, I made that move because I really felt bad using svn, if it works for you there is really no compelling need to change. 现在,我采取了这一举措,因为我真的感觉不好用svn,如果它对你有效,那么真的没有迫切需要改变。 The real task of a programmer is working with code, repositories are just tools that should at least not get in his way. 程序员的真正任务是使用代码,存储库只是至少不会妨碍他的方式的工具。 And that was exactly why svn didn't worked for me. 这就是为什么svn对我不起作用的原因。

Look into Bazaar (bzr). 看看Bazaar(bzr)。 Seriously, it is amazing. 说真的,这太棒了。 Best merge capability I've seen. 我见过的最好的合并能力。

If you are used to Tortoise SVN, then you should try Mercurial, which has a Windows package with a similar shell extension Tortoise HG . 如果你习惯了Tortoise SVN,那么你应该尝试Mercurial,它有一个带有类似shell扩展名Tortoise HG的Windows软件包。 Also Joel Spolsky is using Mercurial at Fog Creek (according to him in one of his podcasts). Joel Spolsky也在Fog Creek使用Mercurial(根据他在他的一个播客中的说法)。

The package is completely stand-alone, I was able to install and use Mercurial right away (doesn't even need a server!) 该软件包是完全独立的,我能够立即安装和使用Mercurial(甚至不需要服务器!)

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

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