Branch difference between Git and SVN

Version control system is a common thing to work with in daily basis for software developers. Git is the most commonly used version control system now a days. Lots of people comes from SVN world to Git currently. There are many differences between SVN and Git.

One main difference between SVN and Git is, SVN manages branches in folders but Git manages branches with pointers. So if I create a new branch from trunk in SVN then it creates a copy of the trunk branch in another folder with the name of new branch. Now as a developer I need to download or checkout the whole folder to work with that newly created branch. But in Git if I creates a new branch from master then it creates a pointer with the new branch name. I do not need to download the full code to work with that newly created branch. I just need to Git checkout the new branch in my same local copy and it is done. It a very fast process in Git in comparison with SVN. I can switch between branches with Git checkout command in my local copy. No need to download different version of folders for different branches. My code is in one copy in my local machine and I can switch between different branches with that.

I am creating a new folder called MyApp for my application. I have added a text file in that. Now I am initializing Git inside that. Open a terminal and initialize Git.

git init

git add .

git commit -m "Initial commit"

By default there is a branch has been created for me called master. I can create new branch from it.

git branch feature1

Now I can switch to feature1 branch.

git checkout feature1

Come back to master.

git checkout master

My working copy is one and I can switch between branches with that. No need to have different copies of folders for different branches in Git like we used to do in SVN.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s