Wednesday, July 26, 2017

Version Controlling

When we  do changes to files existing file is changing over time. Sometimes you may want to see what you have done past. That's the point you will be wanting a version controller which helps you to recall specific version of the file.

Why version Controller? 

Because it allows to:
  • Revert file or the entire project back to previous state.
  • Compare changes over time.
  • If there's an nay error in the current version, you can see who last modified something that cause to the error.
Earlier as a mechanism of version controlling what most people did was to copy files into other directory or time stamped (If they were smart enough). This way seems like so easy but it easily cause to errors. In this way we can accidentally do the modification to the wrong file. 

Local Version Control System

To overcome from the above mentioned problem, local version control system can be used. In this mechanism it uses a simple database that kept all the versions of files. So the user can check out the version of the file that they want. 



Revision Control System (RCS) is the best example for local version Control System. RCS keeps patch sets in a special format on disk. So if RCS user wants to get any version of file, it can recreate it by adding those patches.

Why not Local Version Control System

When it comes to development what most matters is to connect to the other developers who are using different systems. But this mechanism won't allow that.  

Centralized Version Control System

This mechanism has found the answer for the problem that local version controlling mechanism had. In centralized version control system, it has a single server which contains all the versions of files.  So that allows to any number of users to check out or check in files from that centralized server.



Why not Centralized Version Control System

  • Having all the data in one place is a huge mistake. It has higher probability of loosing data. 
  • If the server goes down, no one can collaborate during that time. 

Distributed Version Control System

This is the most recently used and the most reliable mechanism for controlling version so far. In this mechanism instead of checking out the latest version of the file, whole repository is cloned into their local machines. So in case of scenario where server goes down or data got corrupted, one of the any client's copy can be copied back and restore it. 



GIT

GIT is the most popular and the most used version controller. It uses Distributed Version Control System as the mechanism. 

Why GIT

  • Speed
  • Simple design
  • Strong support for non-linear development
  • Fully distributed
  • Able to handle large projects
While other VCs store information based on files, GIT is more likely a set of snapshots of  file system. If one file has no change, then GIT doesn't store that file again. Instead GIT just link to the previous identical file it has already stored. 

Best fact about GIT is nearly every operation is local. Whole project history is in your local disk. You can differ the changes, you can commit to the local database even if you are offline. Latency of network doesn't really matter to GIT.

The other interesting fact about GIT is it checksum before it stores. And the referred to by that checksum. For this GIT is using a mechanism called SHA-1. Basically you can't do any change to files without GIT knowing.

There are 3 stages of GIT

  • Committed
  • Modified
  • Staged



  • Working Directory : Single checkout of one version of the project.
  • Staging Area           : Files which store the information about what will go into your next                                              commit.
  • git Directory           : What we clone from another computer. 
If you are using GIT, there are so methods you can use. I highly recommended command line for GIT.  First because it's good for the best practice. And secondly even though GUIs looks so fancy, most of them implemented few of functionalities of the GIT.  And if you learn how to use command line you can easily learn how to use those GUIs.

Hope you guys got an idea about Version Controllers. If you guys have any thoughts to share, comment down below. See you guys with a new post. :)