Understanding The Web

Version Control: Building, Sharing, Collaborating

Posted

INTRODUCTION

The concept of version control allows for developers to build projects in an organized manner. Version control makes it easier for developers to share code with contributors across the world. Version control also allows for easy collaboration which can immensely enhance a web developer’s growth.  There are many version control software solutions that developers can chose from.  Git is a distributed open-source solution for version control.  While there are many graphical user interface (GUI) clients that developers can use to interact with Git, using the terminal and understanding basic commands offers a deeper understanding.  GitHub is a hosting service that aids in the management of Git repositories.  For developers interested in accelerating their growth and working with others, learning Git is a worthwhile endeavor.  

WHAT IS VERSION CONTROL?

The main idea behind version control is to allow a project to grow incrementally by implementing small changes.  The foundation of this system is the repository.  Repositories contain all of the project’s files as well as a history of all the changes made to the project.

Version control can be broken down into different types.  Some sources claim three types: local, centralized, and distributed. Others sources mention two other types: lock based and optimistic. Lock based systems lock a file allowing only one person to work on it at a time. Optimistic systems allow multiple people to work on a file simultaneously with the system updating the main file whenever a developer is ready to save.

Local version control systems allow for each developer to work independently with a database that keeps track of all changes. Centralized systems contain one repository that receives all the changes. Individual working files are updated as changes are made to the central repository. Distributed systems allow for developers to work on their own repositories.

Developers have a variety of options for version control management

WHAT IS GIT?

Git is an open source distributed version (revision) control system.  The Lunix development team created Git in 2005.  Today, Git is available to download for all major operating systems. 

Unlike other version control systems, Git uses the concept of snapshots.  While other systems rely on updating files, Git creates a snapshot anytime a change is made.  This powerful feature allows developers to visit older snapshots of the project offering flexibility in the development process.  While centralized systems rely on connectivity to the central server, Git stands out due to the fact that developers can commit even while they are offline.  Working offline is possible because of the nature of the distributed system which involves developers working on their own personal repositories. 

An important concept developers working with Git must understand is the idea of “The Three States”.  When working with a Git repository, files exist in three states: modified, staged, and committed. Modified files need to be staged. Staged files need to be committed.  Finally, committed files need to be pushed to the main repository.

Git branching is another fundamental concept that must be understood.  Branches allow for developers to experiment with their project without affecting the main branch.  Projects exist on the main branch by default when a Git repository is created.  Developers have the option to create new branches to experiment with features which may eventually merge with the main branch.

THE COMMAND LINE

Git was designed as a command line tool.  When beginners get lost, most of the online resources will offer solutions in terms of the command line.  Using the command line allows for all git commands to be utilized.  Git has an extensive list of commands.

For those who don’t want to use the command line, there are a variety of graphical user interfaces (GUI) available.  The downside is that most GUIs, unlike the command line, do not have access to all Git commands

Linux and Mac users have easy access to the command line using their built in terminals.  Windows users will be provided with Git Bash upon installation. Git Bash simulates the terminal Linux and Mac users are accustomed to.

WHAT IS GITHUB?

GitHub is one of many choices to host Git repositories.  In terms of users, GitHub is the most popular choice to work with Git projects.  GitHub is a hosting platform that allows developers host their Git projects online. 

Developers can create repositories through GitHub.  The repository can be open to the public or made private.  The idea is to create copy of the repository locally, make changes to the local files, and push the changes onto the repository hosted by GitHub. 

GitHub allows for easy branch management.  While branch management can be performed through the GitHub website, managing branches through the command line is ideal.  Getting accustomed to creating repositories through the command line and uploading the project onto GitHub are fundamental steps to master.

CONCLUSION

Version control allows developers to incrementally build their projects.  Sharing projects becomes much easier.  Another valuable aspect of version control is that it encourages collaboration.  While there are many choices available, Git is a popular distributed version control system.  Understanding the different states of Git and being able to work with branches are the first steps to understanding Git.  Mastering the command line unlocks the full potential of Git.  GitHub’s hosting service makes it easy to work with Git.  Version control is a useful tool developers should consider adding to their projects.