Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between SVN and Git for merging?

Tags:

As the title suggests, I am curious as to why so many people tout Git as a superior alternative to branching/merging over SVN. I am primarily curious because SVN merging sucks and I would like an alternative solution.

How does Git handle merging better? How does it work?

For example, in SVN, if I have the following line:

Hello World!

Then user1 changes it to:

Hello World!1

then user2 changes it to:

Hello World!12

Then user2 commits, then user1 commits, SVN would give you a conflict. Can Git resolve something simple as this?

like image 592
Alexander Avatar asked Apr 22 '10 17:04

Alexander


People also ask

What is the main difference between SVN and Git?

The difference between Git and SVN version control systems is that Git is a distributed version control system, whereas SVN is a centralized version control system. Git uses multiple repositories including a centralized repository and server, as well as some local repositories.

Should I use Git or SVN?

SVN is better than Git for architecture performance, binary files, and usability. And it may be better for access control and auditability, based on your needs.

What does SVN merge do?

This basic syntax— svn merge URL —tells Subversion to merge all changes which have not been previously merged from the URL to the current working directory (which is typically the root of your working copy).

What are the different types of Git merge?

Git merging combines sequences of commits into one unified history of commits. There are two main ways Git will merge: Fast Forward and Three way. Git can automatically merge commits unless there are changes that conflict in both commit sequences.


1 Answers

That is called on merge with conflict, and no VCS will ever solve that for you.
You will have to manually solve the merge yourself.

As mentioned in Why merging in git is better than SVN, the actual difference is in the history recording of commits:

  • linear for SVN
  • DAG (Directed Acyclic Graph) for Git

That allows Git to remember what has already merged, reducing considerably the conflicts occurrences.

DAG

So, when it comes time to do merge from 5b over to the (a) branch, we can use information in the DAG to know that 3b and 2b are already done


So it is the merge workflow that Git will handle much more gracefully than SVN:
See Merge Git vs. SVN for concrete examples.

like image 187
VonC Avatar answered Oct 28 '22 04:10

VonC