Source code is the basis of all those thousands of applications we’ve come to rely on every day. Developers make use of a huge range of programming languages to create the advanced functionality many of us take for granted. And with updates and new versions constantly becoming available, the latest fixes and up-to-the-minute features are just a click away.
That’s a lot of code, and keeping track of it would be virtually impossible without version control. Git is the world’s favourite version control software, making it the go-to tool for most developers looking to effectively manage projects and collaborate across teams.
GitHub is a hosting service for Git repositories, adding even more scope for development and collaboration with its unique online features. But how does Git actually work? What does GitHub add? And why should you care about version control in general?
Why version control is important
What is version control? Also known as source control or revision control, it’s the process of tracking multiple versions of software, often worked on and updated independently by multiple users. In its most simple form you could think of it as the ‘track changes’ features found in word processors.
The aim of version control is to eliminate the complexity of manually maintaining multiple versions of files, and the potential errors and conflicts that come along with it. For example, if two users are working on a file at the same time, changes made by one user run the risk of overwriting those made by the other. But with a version control system, all changes are saved in separate files to ensure that no work is ever lost.
Version control basically allows a project to be continually updated and improved, while preserving previous versions and keeping everything clearly documented along the way. For large teams developing projects with extensive feature sets and intensive release schedules, version control is vital for delivering and maintaining applications.
Another benefit of version control is how it can provide access to source code and development history to people outside the project. This is ideal for open-source projects, with a platform like GitHub providing an easy way for developers to access code and collaborate.
Git back to basics
Before you can understand GitHub, you need an idea of how Git works. An open-source project, Git was created in 2005 by Linux creator Linus Torvalds, as a version control tool for development of the Linux kernel. Based on Torvalds’ experience working on Linux, Git is designed for tracking changes in files, with the scalability to manage large and complex development projects.
Git uses concepts common to version control systems as a whole, but it’s worth defining them here. A ‘branch’ is when a set of files is separated from the others to be developed independently from the main line of development, while this main line (not a branch) is the ‘trunk’. Branches can continue separately, or have their features ‘merged’ back into the trunk at a later date. A repository or ‘repo’ is where the current files and historical data are stored, either on a server or a local machine.
Git’s focus on non-linear development means rapid branching and merging is very much possible. It’s a distributed version control system, meaning each developer can work on a project on their own machine with a full repository, independent of a network or central server. Each developer has a full copy of the development history saved locally, while changes can easily be copied across to other repositories as branches and merged.
So what is GitHub?
GitHub is an online platform for hosting Git repositories. It includes all the functionality of the Git version control system, plus its own unique features. With over 20 million users and 57 million repositories, GitHub is the largest source code hosting service. And while GitHub is mainly used for source code, it can provide version control for any type of file or document.
By default, Git is accessed via a command line interface (CLI). But with GitHub, you get a web-based graphical user interface (GUI) that provides a more user-friendly experience – and GitHub projects can still be accessed via the standard Git CLI. GitHub also adds security and issue tracking features you won’t find in the Git software, with a wide range of clients and plugins available to suit the needs of individual developers and projects.
So GitHub provides a place to host Git repos, plus some extra features. But the real power of GitHub lies in its huge potential for collaboration. When it comes to open-source projects in particular, GitHub is the ideal platform for development that receives contributions from global communities. It achieves this through powerful functionality including forking, pull requests and merging.
Fork, pull request and merge
The three big features of GitHub, these enable the unparalleled levels of collaboration that the platform has become known for. A fork is when source code from an existing project is independently developed into new software. ‘Forking’ implies more than just a branch from the main line of development; usually a fork is created as a distinctly separate piece of software, often by a new team or a group of developers breaking away from an existing organisation.
GitHub allows anyone to take open-source code and create their own fork. Forks can then be released as a new repo, with the option to create a pull request. This is when someone wants their fork to be recognised by the original source code developers, and potentially integrated into the official repo – what’s known as a merge.
Before GitHub, a developer looking to contribute to a project would first have to find a way to download the source code, before making changes on their local machine. Then a pull request would take the form of an email to the project owner detailing changes to the source code. GitHub automates these processes within a single intuitive interface, making it the ideal platform for forks, pull requests and merges.
GitHub: a social network?
The other powerful aspect of GitHub is its social networking features. Personal profiles, feeds, followers and wikis provide even more scope for communication between developers. With a history of all the projects they’ve contributed to, a developer’s GitHub profile acts as a kind of online CV to highlight previous work and achievements.
Public discussion gets people talking about the latest projects and revisions – encouraging conversations between developers who might never get in touch under normal circumstances. The result is a community that embraces collaboration and innovation.
Thinking about contributing to projects on GitHub yourself? For any developers working on high-performance applications, Fasthosts cloud hosting offers the ideal platform, with dedicated resources, scalable on demand, plus UK data centres and expert support available 24/7.