Pages

Sunday, December 4, 2016

GIT




               It is the widely used Version Control System. It an actively maintained Open Source project initially developed  by Linus Torvalds, the famous creator of the Linux operating system kernel. 

     Git owns many forward characteristics compared to other software version control systems  in the fields of Performance, Security, Flexibility etc.  Some of the  especial characteristics are  stated below.


  • Committing changes, merging, branching are optimized for performance
  • Unlike other version control systems, Git is not fooled by the name of the file in determining the history  and it focuses on the file content.
  • Git  Repository are secured with cryptographically secure hashing algorithm SHA1. Thus protects the code and the change history against malicious change.
  • It supports various kinds of non-linear development  workflows 
 In this blog we will discuss on the Git branching feature and the Git Tag feature procedures. Thus is suitable for a one with the basic git command knowledge.


Git Branching  




There is a central repository referred to as the Origin.  Each developer push and pull to the origin. But besides the central push-pull relationship ,  there is an Decentralized  feature to form sub-teams and pull changes form these peers  before pushing the work to the Origin.

For that Git contains branching feature. What is the use of keeping the code in a separate branch.

  1. You are about to make an implementation of major or disruptive change
  2. You are about to make some changes that might not be used
  3. You want to experiment on something that you are not sure it will work
  4. When you are told to branch out, others might have something they need to do in master

 There are mainly two types of branches helpful for a systematic development procedure. They are
                                                           01) Main Branches
                                                           02) Supporting Branches


Main Branches

They are in the central repository and holds down two branches as master and develop. These two branches are parallel.

   Master        => main branch which reflects the source code in the production-ready state.

   Develop     => main branch which reflects the latest delivered development changes for the next   release.


As shown in the diagram, after the initial development version if there are any new features to be added these developments are done in the develop branch. 

When the source code in the develop branch reaches a stable point,and ready to released, then source code is merged with the master branch

Supporting Branches


Next to the main branches master and develop,  there are variety of support branches to support the parallel development between team members. 
Unlike main branches, these have a limited life time period, since they will be removed eventually.

These type branches are categorized by how we use them. for an instances, see the figure below with an Feature branch. 

Feature branches above are for the new feature developments for distant future releases.  The Feature branch will exist as long as the feature is in development. Eventually it is merged back to the develop branch which is shown in the figure.

Feature branch typically exist in developer repo only and not in origin.


Creating a feature branch

When developing a new feature, begin it in a feature branch. To begin it
                                         `$ git checkout -b myfeature develop`

Then you will checkout from the develop branch and switch to the branch "myfeature". Once the feature development is over in the supporting branch, changes have to be incorporated to the develop branch for them to be added to the upcoming release. 

For that  first switch to the develop branch
                                          `$ git checkout develop`

Then merge the myfeature branch to the develop branch. Here --no-ff flag always create a new commit object. This avoids  the loss of historical existence info of the feature branch
                                          `$ git merge --no-ff myfeature`

Then delete the feature branch as 
                                          `$ git branch -d myfeature`
Lastly push the committed change to the develop branch 
                                          `$ git push origin develop`



The first diagram shows the above described process. The second diagram shows the merge without the flag. 
  There are other two supply branches as Release branches and Hotfix branches. It is about the basic branching system of the Git. 



Git Tagging

 What is a tag in Git?

 Tag is used in the version maintenance of a software system. Tag is a way to mark a point in time in your repository.  In other words a tag represents the version of a  particular branch at a time whereas the branch is a separate thread of development.  

In Git we are not tagging branches and we are tagging commits.  We can say tag is an annotated pointer to a commit. It is shown in the figure below.

  Let's see some operations with tags. 

Listing Your Tags  => list all the available tags in Git

                                       $ git tag


                               => list tags with a particular pattern
                                     $ git tag -l "v1.8.5*"


Creating Tags        => two types of tags as lightweight and annotated

                                     lightweight tag is like a branch that doesn't change. Its just a pointer to a                                                specific commit.

                                     annotated tags are stored as full objects in Git database.  They contain                                                    information like tag name,  email, tag message, date etc. 
                                 
Annotated Tag Creation =>   $ git tag -a v1.4   -m "my version 1.4" 
                   -a specifies an annotated tag and -m for the tag message.
                                     using git show command information can be seen. 
       


Lightweight  Tags  Creation => $ git tag v1.4-lw 
                                                      This time git show command does not show any detail. Instead                                                                shows the command