What is Version Control System in Software Development?

Author - Bipin Fultariya

About Version Control System :-

Before we start more about Version Control System lets see what is Version Control System (Revision Control or Source Control system).    – Version Control System or Revision Control or Source Control system is the management of changes to files in large websites, computer programs,  and other collections of information. It is most commonly used in website development, where more than one developers are working on same project or files. In that case, changes are usually identified by a number or letter code, termed the “revision level”,”revision number”,  or simply “revision”.

Why do we need Version Control System(VCS)?

When you want to changes in your current working file and you want to backup this file before doing any changes how you do that?

Some solution like :- Make a backup copy of a file with a different name (e.g. File_old.txt) . This is the solution for school/college project or for very simple project. But For large software projects with many authors, is it possible to manage like this?    So now use of Version Control System is introduced. Which is used to track every changes done in your project files.

How we use Version Control System(VCS)?

There are many version control systems are available like CVS, Git, SVN, Mercurial, Monotone etc. You can choose whichever is suitable for you. But Git is most popular Version Control System. We have considered Git for this blog and all the examples below.

Here are steps to follow to setup Git in your project :-

1) Create a free account on https://github.com or http://gitlab.com   

2) Create a repository.

3) Then set up your project with git.

Now let’s understand key features of VCS using Git examples:

 

Main features of Version Control (with an example of git command line)

1) Backup and Restore

Backup and Restore are simple. It means git will backup our file and we can restore that backup file whenever we need in future.

2) Synchronisation

It’s pretty easy for all members of the project to syncs their file changes with other members.

3) Short-term undo

If you mixed in your file and you need previous changes back then go back to the last version.

4) Long-term undo

Sometimes we mess up very badly. Suppose you made a change a month ago, and it had a bug. Just jump back to the old version, and see what changes were made on that day.

5) Track Changes

When you made any changes in the file and add to git you can add specific message about changes you did at the time of commit your files on git. So you can easily track your changes by that message.

6) Track Ownership

VCS add every changes with a name of the user who makes changes so you can easily track the name of a user with specific changes.

7) Branching and merging

If you have any specific task which is going to take more time to complete and you want to do those changes after completion of other tasks, then you can create a branch for this task and merge in your main branch when it is fully completed.

Basic Functionality Of Git

Config

Configure your git account with your system

Command: git config –global user.name “Your name”

git config –global user.email “yourname@provider.com”

Init

Create a new local git repository.

Command: git init

Clone

check out of exiting git repository in your local system.

Command : git clone /path/to/repository or git clone username@host:/path/to/repository

Status

List the changes file which is still needed to commit.

Command: git status

Add

add one or more changed file.

Command : git add or git add * (add all changes)

Commit

commit your added changes to head (it’s in your local not remote repository yet)

Command: git commit -m “Any message” (add a message for specific commit so you can track it later) or git Commit -a (commit any files you’ve changed since then)

Push

Add changes to your remote repository

Command: git push origin master (push on master branch) or  git push origin <Branch Name>

Remote

check or connect to your remote repository

Command: git remote -v (list of all your remote repository) or            git remote add origin (Add the remote repository to your existing folder or project)

Branches

Create,  Switch, Push into Branches

Command:

-git checkout -b (Create a new branch and switch to it)            

-git checkout (Switch to branch name)            

-git branch (List all branch of your current repository and also tell which one you use right now)            

-git branch -d (Delete specific branch)            

-git push origin (Push branch to your remote repository, so others user can use this)            

-git push –all origin (Push all branch to your remote repository)            

-git push origin : or git push origin –delete   (Delete Branch from your remote repository)

Pull

Get updated changes for your remote repository

-git pull (Fetch and merge changes from the remote repository to your local working directory)

-git merge (Merge your specific branch to your branch)

-git diff (Check all merge conflicts)

-git diff –base (View conflicts again the base file)

-git diff (Show changes, before merging)

note : after you manually resolve conflicts you need to add the changes using git add

 

Tags

You can mark your commit with specific tags (i.e. release version)

– git log (For getting commit ID you can use this command)

– git tag 1.0.0

– git push –tags origin (Push your tag to the remote repository)

– git tag -d 1.0.0 (Deltet tag)

Others:

– git checkout — (discard uncommitted changes to the filename)

– git fetch origin (Fetch the latest commit from a server) and git reset –hard origin/master (point your local master branch)

Don’t miss the next post!

Loading

Related Posts