git vs svn

Git version control is a distributed. SVN is centralized. But that's just the beginning. There are also key differences in repositories, branching, and more. Keep reading for the full differences.

  • How It Works

Git software is installed on a workstation and acts as a client and a server. Every developer has a local copy of the full version history of the project on their individual machine. Git changes happen locally. So, the developer doesn’t have to be connected all the time. Once all the files are downloaded to the developer’s workstation, local operations are faster.

SVN has a separate server and client. Only the files a developer is working on are kept on the local machine, and the developer must be online, working with the server. Users check out files and commit changes back to the server.

Conflict

  • What is a merge conflict?

In every situation where work can be parallelized, work will eventually overlap. Sometimes two developers will change the same line of code in two different ways; in such a case, Git can't tell which version is correct—that's something only a developer can decide.

If this happens, a developer will see the following error during a git merge:

Auto-merging [filename1]
CONFLICT (content): Merge conflict in [filename1]
Automatic merge failed; fix conflicts and then commit the result.

Resolving merge conflicts can take a minute or they can take days (if there are a lot of files that need to be fixed). It's recommended, and good coding practice, to sync your code multiple times a day by committing, pushing, pulling, and merging often.

  • How do you resolve a git merge conflict?

Git gives a clue to resolving conflicts in its error message. It says Merge conflict in [filename1], so you know there is a problem with that file. Then it says fix conflicts and then commit the result, so if you follow directions, edit the file, then commit it, everything should work fine. Let's see this in action.

你可能感兴趣的:(git vs svn)