Why Learn Git

From Coder Merlin
Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder
Git Logo

When working on a group project, it is typical to have multiple moving parts—presentation slides, talking points, bibliography, and write-up. To ensure continuity and cohesion, it is important to divide up the work and to stay informed about the changes people are making to the project. As a result, tools like Google Docs, Google Slides, and Google Sheets are very popular. They allow multiple users to track changes over time and collaborate on the same document, presentation, or spreadsheet—all in realtime. Similarly, in the software community, coders need tools to help them work together and to document updates as they write code and identify and fix bugs. Many software tools are available to help programmers achieve these goals. One of the most important and relevant tools is Git.

Origins of Git[edit]

Version Control[edit]

Version control's roots are in the manufacturing industry, where many engineers were building different parts of machines. They could build each part somewhat independently, but big changes to one part could alter some of or all the other parts. This required tracking the different changes made by many collaborators over time.[1] In software, version control or a version control system (VCS) allows users to track and manage changes to a file or a set of files, and revert back to earlier versions as necessary.

Throughout the history of version control's use in software, different kinds of VCSs, as described by Scott Chacon and Bob Straub in their book Pro Git (2014). First, local version control systems, were used, which kept track of changes made on the local device. Essentially a local VCS works like saving multiple drafts of a paper at different stages. You can access them only on your computer, and the different versions exist only on your local device. Local VCSs are great if you are working alone on a personal project. However, they are less helpful when you are working with a partner or multiple collaborators who all need access to the different versions of the code at different times.[2]

Central version control systems solved the collaboration issue by saving all the different versions of the files on a central server. Multiple users could then work on the files by checking them out from the central server. However, there remained an issue with central VCSs that local VCSs also had—there was only one location that maintained the entire version history of the files. If something happened to the central server (or local server), everything could be lost and might be irrecoverable.[2]

Correcting this flaw led to the need for distributed version control systems, like Git. In a distributed VCS, users' local file repositories mirror everything in the remote (centralized) repository, including the entire version history of all the files. As such, several full data backups of the entire project history are available on each users' local server and on the remote server, minimizing the effect if one server fails.[2]

Exit BitKeeper, Enter Git[edit]

BitKeeper Logo
Git Data Flow

Developers working on the Linux operating system, which powers every Android device and major websites like Facebook and Wikipedia, had been using BitKeeper, a proprietary software, for free since 2002. BitKeeper is a distributed VCS designed specifically for the Linux community to use. Larry McVoy, a close friend of Linus Torvalds—the creator of the first Linux operating system—originally designed BitKeeper.[3]

But in 2005 the partnership between BitKeeper and the Linux community dissolved. A few factors were involved. First, McVoy learned of a Linux user attempting to develop their own VCS based on BitKeeper, which McVoy argued went against BitKeeper's licensing agreement with Linux. Additionally, McVoy determined it was no longer feasible to maintain the cost of covering the Linux community's usage, an estimated $500,000. McVoy wanted to recover his costs. However, Torvalds refused to pay. In part, this was because of vocal displeasure among open-source community members that the Linux developers were using a privatized service for version control.[3] Within 2 weeks, Torvalds developed his own open-source distributed VCS, called Git, to replace BitKeeper. Since Torvalds first released Git, it has been updated and modified to improve usage. Git has also exploded in popularity.[4]

What is Git?[edit]

Git Branching

Git is a distributed VCS software and, along with BitKeeper, popularized the distributed VCS model.[1] Distributed VCSs allow users to commit changes locally, and work by having users retain a full copy of the entire version history locally and remotely.[5]

However, Git handles and stores data differently from many other VCSs. Chacon and Straub describe Git's data as "a stream of snapshots." When a file remains unchanged from commit A to commit B, Git just links to the same file that was already stored in commit A rather than storing the file again.[2] Additionally, while other VCSs have branching functionality, Git's is much faster and more lightweight, allowing users to branch and merge within projects frequently. (Branching in version control allows for parallel work streams based on the same base code. Each individual branch can then be modified independently. Merging in version control combines these parallel work streams into one functional version of the whole project.) In other VCSs, branching can be expensive, sometimes requiring the entire file repository to be copied over, but in Git, a branch is just a pointer to a commit. This makes it easy to create and destroy branches.[6]

GitHub Logo

Git vs. GitHub[edit]

GitHub, not to be confused with Git itself, is essentially a tool to make using Git easier. GitHub is a popular web-based service that hosts Git repositories, provides additional functionality to help coders use Git, and allows them to collaborate on projects.[7] In 2008 Chris Wanstrath, Tom Preston-Werner, and PJ Hyett released the beta version of GitHub. When Microsoft acquired GitHub in 2018 for $7.6 billion, millions of software developers, companies, and institutions were using the site.[8]

Reasons to Learn Git[edit]

Optimize Learning as a Beginner[edit]

Like any other popular tech tool, you will find several reasons to add it to your toolbelt. First, as a beginner, Git is an exceptional tool to optimize your learning and process through your first few projects. Being able to track your changes over time and write documentation through git commit is invaluable. You will be able to review your code a lot more easily in the future if you write quality commit comments. But, it is important to develop good practices early on. This includes writing good Git commit comments, creating branches when adding a new feature, and resolving merge conflicts. Additionally by using a service like GitHub, you can easily create a public, sharable portfolio of any project right from the start. Even if you don't make your first project public, the process will give you good practice when you do want to showcase a project. [9]

Learning Skills for Internships & Jobs[edit]

Beyond improving your early skills and developing a portfolio, Git is an important professional skill to have for internships and jobs. Many companies use Git, and if they don't, they probably use some other kind of version control. Git is a great, free, widely used, open-source option that you can use to gain experience.[10] When applying to jobs and internships, some companies also provide a space to add your GitHub link, so it is a good idea to have a few projects to display. When preparing for interviews, you can then revisit these personal projects for improvements, and to use git log to review your process throughout the projects.

Open-Source Community[edit]

Last, as with the other open-source tools and resources that CoderMerlin provides you opportunity to use, like Swift and Linux, Git has a community of resources, forums, and millions of users that are at the disposal of any coder. As a result, lots of free educational resources are available on Git, GitHub, GitLab, Stack Overflow, Udemy, etc. We will review some of these in the following section.

Get Started Learning Git[edit]

As promised, many resources are readily available for you to get started on Git or to answer any advanced questions you might have. It is best to start at the source. Of course, reading and watching pales in comparison to actually doing. By using CoderMerlin, you can gain experience initiating Git repos, making changes, adding and committing those changes, rolling back errors, and more. git init your first Git repo today, for your future projects!

Key Concepts[edit]

Key ConceptsKeyConceptsIcon.png
  • What is version control?
    • Version control or version control systems (VCSs) are software tools that allow coders to document changes made to code over time and to collaborate easily on projects.
    • One key component of VCSs that allows for collaboration is branching, which creates independent, parallel work streams that deviate at a point in the code.
    • VCSs have gone through several iterations
      • Local Version Control Systems
        • Weaknesses: difficult to collaborate and, if the local server goes down, all version history could be lost
      • Centralized Version Control Systems
        • Strength: allows collaboration via centralized server
        • Weakness: if the centralized server goes down, all version history could be lost
      • Distributed Version Control System
        • Strength: allows collaboration via centralized server AND a copy of the entire version history is available on every local and centralized/remote server
  • What is Git?
    • A free, open-source distributed VCS developed by Linus Torvalds in 2005, originally adopted by the Linux community
    • Deviated from other VCSs in its handling of branches, and helped popularize the distributed VCS
    • Not to be confused with GitHub, which is a web-based service that hosts Git repositories
  • Why learn Git?
    • Git is a great tool especially for beginner coders to hone their skills and to showcase any portfolio projects.
    • Git is a relevant job skill for those seeking internships or jobs. Even if Git specifically is not used on the job, it is very likely that another VCS is, and practicing with a popular VCS is a good start.
    • Because Git is open-source, there is a community of coders backing and supporting it. Additionally, a variety of free resources is available to kickstart learning Git.
    • Using Git and GitHub is a way to start showcasing a portfolio of work.
  • How to learn Git
    • Many free resources are available on Git's official website (https://git-scm.com/) and on GitHub's official website (https://docs.github.com/en)
    • Many other courses, blogposts, and forums are available through a simple Google search. Find what works best for you.
    • Keep working with CoderMerlin to gain first-hand experience using Git