Skip to main content

Section 12.7 What are Git and GitHub?

In the previous section, we saw the problems that arise from managing code versions manually (_v1, _final, etc.) and the need for a systematic solution. Version Control Systems (VCS) provide that solution by tracking changes over time. Now, let’s introduce the specific tools you’ll most commonly encounter and use for this purpose, including for our ArrayList project.

Subsection 12.7.1 Git: Your Local Version Tracker

The most popular and widely used VCS today is called Git. Originally developed by Linus Torvalds (creator of Linux), Git is a powerful tool installed and run directly on your computer. Its primary job is to track changes to files within a specific project folder.
Here are the core ideas behind Git:
  • Snapshots, Not Differences: Instead of just recording what changed between versions, Git primarily stores "snapshots" of what all your project files looked like at a particular point in time.
  • Repository (Repo): When you use Git on a project, it creates a special hidden sub-folder named .git inside your main project folder. This .git folder *is* the Git repository – it contains the entire history of all your snapshots (commits) and other necessary tracking information. Your main project folder combined with this .git subfolder constitutes your local repository.
  • Local Operation: Most Git operations (like saving a snapshot, viewing history, comparing versions) happen entirely on your own computer using your local repository. You don’t necessarily need an internet connection for basic version tracking.
  • Distributed: Git is a *distributed* VCS. This means that when multiple people collaborate, each person typically has their own complete copy of the repository, including its full history. This differs from older centralized systems where the history only lived on a central server. This distributed nature means that even if the central hosting service (like GitHub) is temporarily unavailable, every developer still has the full project history on their own computer, providing resilience.
Think of Git as an incredibly sophisticated tracking system living inside your project folder, remembering every version you explicitly tell it to save.

Subsection 12.7.2 GitHub: Hosting Your Repositories Online

Problem: Git runs locally, tracking history in the .git folder within your project. But what happens if your hard drive fails? Your project history is lost! Also, how do you easily share your Git-tracked project with others or collaborate on it? Emailing the whole folder with its .git directory isn’t practical.
Solution: This is where services like GitHub come in. GitHub (and similar platforms like GitLab, Bitbucket, etc.) is a web-based hosting service specifically designed for Git repositories. It provides a place on the internet to store copies of your Git repos.
Key functions of GitHub include:
  • Remote Storage/Backup: You can "push" your local Git repository’s history up to GitHub, creating a secure online backup.
  • Collaboration: GitHub provides tools built around Git to help teams work together (e.g., managing different proposed changes via Pull Requests, tracking tasks via Issues). (These collaboration features are beyond our scope here).
  • Code Sharing and Discovery: Many open-source projects host their code publicly on GitHub, allowing others to easily find, download (clone), and potentially contribute to them. Educational institutions also use it to distribute starter code for assignments – like our ArrayList project!

Note 12.7.1. Git ≠ GitHub.

It’s crucial to understand the distinction:
  • Git is the underlying version control software that runs on your computer, managing the .git repository locally.
  • GitHub is a website/service that hosts Git repositories online, adding features for backup, sharing, and collaboration on top of Git.
Analogy: Think of Git like a powerful word processor (like Microsoft Word or LibreOffice Writer) installed on your computer for creating and editing documents locally. Think of GitHub like a cloud storage and collaboration service (like Google Drive, OneDrive, or Dropbox) where you can upload, store, share, and potentially co-edit those documents online. You use the local software (Git) to manage versions, and the online service (GitHub) to store and share those versions.
For our capstone project, the starter code, ADT interfaces, and tests for the ArrayList are stored in a Git repository hosted on GitHub at https://github.com/Charlotte-CCI-ICC/1213-arraylist-example.git. To get started, you’ll need to use Git to create your own local copy of this online repository. This process is called cloning, which we’ll cover next.
You have attempted of activities on this page.