What makes Git better than Subversion for merging? [duplicate]
Possible Duplicate:
Merging: hg/git vs. svn
I've heard/read that Git and DVCS's in general are better than Subversion and centralized version control systems. And one of the reasons I've heard for this is that merging is so much better in DVCS's than in centralized system.
开发者_运维技巧What is the difference between the two when it comes to merging? What makes Git better than Subversion when you're re-integrating a branch, for instance?
It's not so much the fact that they're distributed, but more that they keep track of changesets rather than versions. (However, distributed systems usually work with changesets, while centralized ones often use versions; this is because distributed systems just won't work with a version-based approach, while centralized systems can get away with it).
Subversion says, OK, first I had this version and then I had that version. And then when it's time to merge, it takes the two versions, compares them, and makes educated guesses on how to combine them. Git, mercurial, and similar SCMs, say, OK, first I had nothing, then someone made this change and then someone else made that change, etc. When it's merge time, basically all they need to do is apply the changes in the correct order, correcting for line numbers here and there and taking file renaming into account, but that's basically it.
Subversion doesn't really have enough information to perform an intelligent merge: it only sees the differences, but not where they come from.
Linus torvalds did a talk on git, available on youtube and worth watching. In it, he dismisses all source control solutions but git, then explains why git is great.
Personally, I found git frustrating to get to terms with and I use SVN professionally every day. I think svn is fast enough and does branching & merging well enough for my needs.
But I'm no source control expert!
精彩评论