GitHub & Version Control

Avatar for Matthew Matthew 25th October 2019 0 Comments

What is it?

At its core, GitHub is a website and cloud-based service helping developers store and modify their code whilst changes are tracked and stored like a special type of database. This way, if anything goes wrong or a bug arises, developers can role back to previous versions and adjust their code from there. This is called version control, helping developers track and manage changes on the code of a project. The ‘Git’ in GitHub represents a specific open-source version control system, it is also distributed, meaning that a codebase or project is available on each developer’s computer providing the ability for easy branching, typically through the command line interface.

 

Version Control

Essentially, version control helps a developer, or a team of developers, track changes and manage those changes. If it is a large project for example, you can imagine the complexity of the codebase and without version control, you would have a one absolute base without the ability to roll back to previous changes easily. A good example of this is WordPress, an open-source software used to make websites, blogs and apps. If a developer needed to make a change to a component within WordPress, it would be a risky task if directly modifying the source code, so instead, version control allows branching and merging.

Branching is the process of duplicating the source code, that exists within a repository, where the developer can then make changes to the specific code base necessary. Once any changes have been made, the developer can then merge the code into the main source code, making it ‘official.’ Obviously, all these changes are now tracked and can be reverted if it was ever needed.

 

GitHub

Now version control and Git has been explained, it is good to understand how the interface of GitHub works and how to use its version control abilities. Take a look below to see how it works;

  • Repository
    A repository or ‘repo,’ is the base location where all the files for a project are stored, it can have folders and any type of files (HTML, CSS, JS, Images and more).

 

  • Forking a Repo
    ‘Forking’ is the process of creating a new project based on another project that already exists. For example, if you see a project you like and want to make changes to do, you can fork that repository, make any necessary changes you need to and release that project as a new repo. Any changes made to the original repo, such as updates, can then be added to your current fork if needed.

 

  • Pull Request
    After forking a repository and making changes to it, a developer can then pursue a Pull Request for those changes to be included with the initial and official repository of that project, allowing you to be recognised by the original developers. GitHub provides a medium for you and the main projects developers to communicate and decide whether or not it should be included officially.

 

  • Branch
    A branch allows for a developer to work with different versions of a repo at the same time, where you can a default master branch (production) and every branch after that is a copy of the master branch. Creating new branches allows for bugs to be fixed and once it is ready, can be merged back into the master branch.

 

  • Commits
    Any changes made to files in a repository are called commits, which are tracked and allow for a developer to explain what they have done with this code change.

 

The good thing about GitHub is that it is relatively user friendly for people who don’t have much programming or command line knowledge. Its interface is so easy, that it’s even used to store personal projects that aren’t code based, such as books. However, if you’re a developer or have a team of developers working on a project, GitHub makes it easy to track the progress and mitigate any problems that could arise throughout development.

Another major advantage of GitHub is that it can integrate with many common platforms, like Amazon and Google Cloud – allowing for a team of developers within an organisation to work with many different programming languages and platforms.