Git for the SVN (subversion) users

Git for the SVN (subversion) users

Git and SVN (subversion) both are excellent versioning control system But there are times when a project runs on Git where else the other one is on SVN. If we talk about the difference between Git and SVN, it certainly needs a separate post but majorly Git is Distributed Revision Control System where as SVN is centralized.

In case of Git we actually work in 3 main states, The Working Directory, The Staging Area and The .git Repository But in case of SVN its only 2 The working Directory and The Repository.

In this post, we will quickly learn the commands that perform the similar jobs in both the VCS. We will discuss the Git and SVN in-depth in separate posts.

How to create a Repository?

GIT

SVN

How to clone a Repository?

In both Git and SVN, we can clone either using the direct http/s url of repository or using the ssh.

GIT

Git clone will setup the full-fledge repository to your local not just the working copy. This means, now your repository can act as origin and someone can clone from your repository as well, just like a regular git repo.

SVN

How to see logs?

GIT
As you posses local copy of Repository, Git log shows the latest available log at the repository. You need to sync your repository with the Origin to get the latest logs. Git pull will do that.

SVN

How to commit changes?

In both Git and SVN, we use add to create new files or directory in the repository. It will stage your changes. We can add file using add command and remove files using rm command.

To see local uncommitted changes in both GIT and SVN repository

To see the diff:

To add or stage the file:

GIT

To remove the untracked files (those not are committed) from the Repository

SVN

How to commit?

Now you have staged your changes, its time to commit them to repository

GIT

Tip: If you want to stage and commit all your files, Instead of adding them manually use -a flag while committing. like:

In order to update the remote repository (default origin) with your committed changes, so that other can fetch that, you need to use git push

SVN

How to create branch or tags?

GIT
In Git, branches are merely pointers and more powerful than in branches in SVN which is the directories and copy of the repository itself. In Git, you always work on a branch. By default, when you create a new repo or clone, you remains in master branch. If you do git branch, it will show you the current branch you are in.
So let’s have a look, How to create a new Branch.

Tip: If you want to switch immediately after creating a branch, Do git checkout -b

SVN

How to switch in branches?

GIT

SVN

How to list branches?

GIT

SVN

How to get information about the Repository/branch/origin?

GIT

SVN

How to create tags?

GIT

SVN

How to Delete Branches?

GIT

SVN

How to Merge Changes?

GIT

SVN

While merging, If you got conflicts, then remove the conflicts from the file and then mark the files resolved like

GIT

SVN

How to update your local copy with latest changes

GIT
If you want to download and merge new changes from the remote repo then do git pull. Git pull internally does two things, first it fetches the latest changes from the remote repo and then it merges them in to your current local branch.

By default, Git operate in the context of your remote repo origin and branch master>

SVN

How to rename files?

GIT

SVN

How to push your local branch to the remote repository in Git

So, that was the quick overview of GIT and SVN. We will see advance usage of GIT like setting upstream, cherry-pick, setting diff editor in further posts.
Till then have fun and Happy Coding !!

Leave a Reply

Your email address will not be published. Required fields are marked *