November 01, 2016

What are the differences between SVN, CVS and GIT?

What are the differences between SVN(Subversion) and GIT?
1). SVN is a Centralized Revision Control System, and GIT is a Distributed Revision Control System (DVCS). GIT like SVN do have centralized repository or server. But, GIT is more intended to be used in distributed mode which means, every developers checking out code from central repository/server will have their own cloned repository installed on their machine. You make changes locally, check in (commit) to your local copy of the repository, and then "push" those change sets to another repository when you want to publish them or share them with other users. You can also "pull" to synchronize with a remote repository.


For example, if you are stuck somewhere where you don’t have network connectivity, like inside the flight, basement, elevator etc. you will still be able to commit files, look at revision history, create branches etc. This may sound trivial for lot of people but, it is a big deal when you often bump into no-network scenario.

And also, the distributed mode of operation is a biggest blessing for open-source software development community. Instead of creating patches & sending it through emails, you can create a branch & send a pull request to the project team. It will help the code stay streamlined without getting lost in transport.

2). GIT stores content as metadata, SVN stores just files. Every source control systems stores the metadata of files in hidden folders like .svn, .cvs etc., whereas GIT stores entire content inside the .git folder. If you compare the size of .git folder with .svn, you will notice a big difference. So, the .git folder is the cloned repository in your machine, it has everything that the central repository has like tags, branches, version histories etc.

3). GIT branches are not the same as SVN branches. Branches in SVN are nothing but just another folder in the repository. If you need to know if you had merged a branch, you need to explicitly run commands like svn propget svn:mergeinfo to verify if it was merged or not. So, the chance of adding up orphan branches is pretty big.

Whereas, working with GIT branches is much more easier & fun. You can quickly switch between branches from the same working directory. It helps finding un-merged branches and also help merging files fairly easily & quickly.

4). In GIT, when a feature is finished, the feature branch is merged into master and deleted. Whereas in SVN, when a feature is finished, the feature directory is merged into trunk and removed.

5). GIT does not have a global revision no, where as SVN’s revision no. is a snapshot of source code at any given time.

6). GIT contents are cryptographically hashed using SHA-1 hash algorithm.This will ensure the robustness of code contents by making it less prone to repository corruption due to disk failures, network issues etc. SVN doesnt have a hashed contents.This will risk to lose code and contents due to disk failure , network issues.

What is the difference between CVS (Concurrent Versions System) and SVN (SubVersioN)?
1. SVN is newer and more advanced compared to the much older CVS.
2. SVN allows atomic commits while CVS does not. Atomic commits allow each commit to be applied in full or not at all. This can be quite useful when the server crashes in the middle of a commit. With SVN, the commit can be rolled back while CVS could not undo the partial commit.
3. SVN allows renaming and moving while CVS does not. With SVN the files that have been renamed or removed still carry their revision history and metadata. CVS is also unable to push any new changes to parent repositories while it can be achieved in SVN with the use of some tools.
4. SVN allows for propagating changes to parent repositories while CVS does not
5. SVN supports two networking protocols while CVS only supports one

SVN is the superior and logical option between the two. It provides the user with the right feature set to match his needs. The only reason to keep using CVS is if you are stuck with a legacy system that is quite difficult to move to an SVN system.

What is the difference between a trunk, tag and a branch in subversion?
Technically all three i.e. trunk, branch and tag are folders in SVN.

A trunk in SVN contains the main codebase and is always stable. In the early days of a project, there will be little need for branches and tags, as you will spend most of your time making changes and committing them back to the trunk of your repository.

A branch in SVN is sub development area where parallel development on different functionalities happens. After completion of a functionality, a branch is usually merged back into trunk.

The Subversion repository remembers every change written to it. This allows the client to read the latest version of the filesystem tree, but also to view the previous states of the filesystem. Users can tag certain revisions of the repository with more human-readable file names (e.g “beta-release-7.0”) for easy reference. In this scenario, if you ever need to look at the source code for version 7.0 again, you can easily locate the tagged file and pull the code back out.  We can say, a tag in SVN is read only copy of source code from branch or tag at any point of time and are mostly used to create a copy of released source code for restore and backup. Main difference between branch and tag in subversion is that, tag is a read only copy of source code at any point and no further change on tag is accepted, while branch is mainly for development.

NOTE: Subversion doesn’t force you to organize your project into trunk, tags and branches, but arranging your data in this conventional format allows you to access the wealth of Subversion tutorials and guidelines online and, of course, it makes it easier to reach out to the community for help if you get stuck

CVS doesn't allow modification on tags, but SVN allows changes on tags, however that is considered as bad practice. One should not be make any change on tag once created, it should be treated as read only copy of source code only for restore purpose.

-K Himaanshu Shuklaa...

No comments:

Post a Comment