Introduction to GIT Version Control System
Git is one of the most common term heard between programmers in the last four-five years. I will present here some insight into this tool and why it is so popular among programmers. In this topic, we are going to learn about GIT Version Control System.
What is and why version Controller?
Linus Torvalds who started the Linux kernel is the person who created this software to maintain and track different versions of source code among the programmers.
Imagine a team of five members who are working on master source code enhancing different features to it. Just think how can they work on the same source code without confusion on each other changes? Each one has to know what others four are doing and there shouldn’t be any negligence to it. And by the end of work hour, they have to spend some time coordinating each other works so that at last one source code is maintained. It looks a lot hectic and definitely manual intervention in maintaining source code is riskier. So to help or to say to automate all these versions on which all the five programmers are working we need properly written version controller and GIT is one of them. There is a term for the above steps and its called Source Code Management or Software Configuration Management (SCM).
Now consider one more scenario where version controller automation helps. We have written the first version of code and the client has approved to install it on production lets this is version 1.0. Now after a few months, client offers enhancement work and you work on earlier written to develop version 1.1 and submit to the client. But the client suggests a different approach and this version 1.1 is not useful to you according to the client’s new approach. So you discard this and work on version 1.2 which gets submitted and approved. And so on you keep working in developing different versions. But don’t you think manually saving all versions somewhere and maintaining source code is not messy? At some point in time, you might need to refer to version 1.1 which you discarded and doesn’t have handy.
So to maintain different versions of code written by one or multiple programmers we use version controllers.
Different Types of Version Controller
There are different types of tools available and below are some of them
- Subversion – Since developed by Apache, used widely by Apache vendors.
Basically, there are two types of version control system methodologies on which the above tools work upon. They are
Centralized Version Control System (CVCS) Distributed Version Control System (DVCS)
Here the code written stored in the centralized repository or in the centralized server. No working copy available at local machines which is a huge disadvantage when there is server failure. I need to have an active server connection always to work on the repo. SVN uses this control system
Here also we have the source code on the server but along with that, we have it as local copy on working machines. So even if there is a failure at the server level we can mirror back the local working copy to the server when it is restored. This availability of local working copy on each machine responsible for the term ‘Dsistriibuted’ in DVCS. Git, Mercurial uses a distributed version control system
Git uses the concept of branching or more technically called as Trunk Based Development TBD. What it actually means is that we can create multiple branches from the master and on these branches, programmers can work and commit their changes to these branches and each of these commits is tracked. And once clients approve we can merge all the branches to the master code in the production. In this way are not impacting the master source code directly. Working on master source code directly will be riskier and needs to be avoided. We can work on branches and perform various testing scenarios and once the final version is stabilized and approved we can work on merging it master which reduces the risk by a significant amount.
Git is actually free and for Mac users, it is available for default. In Linux, we can install git and for Windows, we have something, Git Bash. There are two most popular repository sources where we can work with Git and they are Git Hub and Bit Bucket and organization choosing to base on its preference.
Advantages of GIT Version Control System
Below are some of the advantages described.
- Supports both legacy form of development which is a linear also nonlinear form of development
- Since distributed in nature, less worry on single point server failures. We can always mirror back the code from the local repo to the server.
- We can also implement a security layer on top of git which can assign access restrictions in commit pull and push.
- Can work on multiple platforms like Mac, Linux, Windows, etc
- Absolutely free and open-source
- Efficient and fast because of distributed nature
- Clear tracking of commits, updates, reverts, versions, push and pulls
- Provides GitBash for windows which easy to use.
- There are also various GUI available to work on top of GIT
- It doesn’t require an active network connection always since the availability of the local repository.
Working with Git
- Create the working branch from source master or from another branch depending on the requirement
- Clone the branch on local using GitBash for windows
- Work on the branch and perform modifications or addition of components to it
- Commit the changes and refer commit tracker
- If you feel commit was unnecessary, you can revert the commit to the earlier one
- If multiple programmers working on the same branch then, local repo must be updated before pushing your changes. So perform PULL
- Now you will be able to perform the PUSH
- Once review and code approval did to your branch then we can move the code to production either by ansible or whatever way the organization uses.
- Merge the branch to the Master so that we have updated code in it.
Git is the most commonly used Distributed Version Control System because of its distributed nature, no single point of failure and is open source. You can try working with it using sample code in GitHub and GitBash in windows PC as git commands are simple and easily available online.
This is a guide to GIT Version Control System. Here we discuss the basic concept, different types of Version Controller with advantages and working. You may also look at the following article to learn more –