Version Control with GitHub

1

Version Control with GitHub

▶

Software projects, even small ones, generate a constant stream of decisions: a function is rewritten, a bug is fixed, a feature is added, and then perhaps rolled back when it causes problems. Without a system to track these changes, teams quickly find themselves lost in a tangle of folders named final_v2, final_ACTUAL, and backup_before_changes. Version control solves this problem systematically, and GitHub brings version control into a collaborative, cloud-hosted environment with a rich set of project management tools built right in.

What Is Version Control?

Version control is a system that records every change made to a set of files over time, creating a complete, navigable history of the project from its very first line of code to the present moment. Think of it as an unlimited undo history that is shared across an entire team, stored permanently, and queryable at any point.

At its core, a version control system works by capturing snapshots of the project. Each snapshot is called a commit. A commit records exactly which files changed, what those changes were (lines added or removed), who made the change, and when. Because every commit is stored permanently, the project's evolution is fully auditable: you can open any commit from six months ago and see the exact state of every file at that moment.

Three properties make version control indispensable for any project involving more than one person — or even just one person working over time:

  • Complete history preservation. Every change is logged with its author, timestamp, and a descriptive message. If a newly deployed feature causes production errors, the team can trace exactly which commit introduced the problem and revert to a known-good state in seconds. No work is ever truly lost.
  • Simultaneous collaboration without conflict. Two developers can edit different parts of the codebase at the same time without overwriting each other's work. The version control system tracks each person's changes on separate branches and provides tools to merge those changes together intelligently, flagging only the cases where the same lines were edited in conflicting ways.
  • Full restoration capability. Any earlier version of the project can be restored at any time. This is useful not only for recovering from bugs but also for testing how code behaved at a specific release, auditing changes for security reviews, or simply understanding why a particular decision was made.

Git is by far the most widely used version control system today. It is distributed, meaning every developer has a complete copy of the entire repository history on their own machine. This means work can continue offline and no single server failure can destroy the project history. GitHub is the most popular platform for hosting Git repositories in the cloud and layering collaboration features on top of them.

GitHub as a Collaboration Platform

GitHub is far more than a place to store code. It is a fully featured collaboration platform that supports the entire lifecycle of a software project, from initial planning through deployment and beyond.

Cloud-hosted repositories are the foundation. When a repository is pushed to GitHub, every team member can clone it to their own machine, contribute changes, and push those changes back — all without any manual file sharing. Because the repository lives in the cloud, it is accessible from any device with an internet connection, and it serves as the authoritative source of truth for the project.

Built-in project management tools mean teams rarely need separate task-tracking software. GitHub provides three tightly integrated tools:

  • Issues act as task tickets. A developer can open an issue to report a bug, request a feature, or ask a question. Issues can be assigned to specific team members, tagged with color-coded labels (such as bug, enhancement, or documentation), and directly linked to the commits or pull requests that resolve them.
  • Projects provide Kanban-style or spreadsheet-style boards that give the team a visual overview of all work in progress. Cards on the board correspond to issues and pull requests, so the board always reflects the real state of the codebase.
  • Discussions create a threaded forum space within the repository for broader conversations that do not fit neatly into a specific issue — design decisions, team announcements, or open-ended questions.

GitHub Actions is a powerful automation engine built directly into GitHub. Workflows defined in YAML files can be triggered by events such as a push to the main branch or the opening of a pull request. Common uses include running automated tests to verify that new code does not break existing functionality, checking code style with a linter, building the project, and deploying it to a server. This practice — automatically testing and integrating code changes — is called Continuous Integration/Continuous Deployment (CI/CD), and GitHub Actions makes it accessible even to small teams.

GitHub Copilot is an AI-powered coding assistant that integrates directly into editors like Visual Studio Code. It reads the context of the code being written and offers real-time suggestions for completing lines, writing entire functions, generating test cases, or explaining unfamiliar code. For learners and experienced developers alike, Copilot accelerates the writing of boilerplate code and helps explore unfamiliar APIs without leaving the editor.

Creating and Configuring a Repository

A repository (often abbreviated as repo) is the container for everything related to a project: all source files, the complete history of every commit, branch information, and the metadata that supports collaboration. Setting a repository up correctly from the start saves significant headaches later.

When creating a new repository on GitHub, several decisions matter immediately:

  • Visibility. A public repository is visible to anyone on the internet (though only authorized collaborators can write to it). A private repository is visible only to invited collaborators. Most team projects start as private and are made public only when ready.
  • Initializing with a README. Selecting this option creates the repository's first commit automatically, which makes it immediately cloneable.
  • Choosing a license. For open-source projects, a license defines how others can use, modify, and distribute the code.

The README file (README.md) is typically the first thing a visitor or new team member reads. A well-written README covers the project's purpose in plain language, the technologies it uses, step-by-step instructions for setting up a local development environment, how to run tests, and guidelines for contributing. Because GitHub renders Markdown automatically, the README can include formatted headings, code blocks, and links without any special tooling.

The .gitignore file tells Git which files and directories to ignore — that is, never to track or commit. This is critically important for two reasons. First, many files generated during development (compiled binaries, dependency folders like node_modules/, editor configuration files like .DS_Store) would pollute the repository with noise. Second, and more urgently, sensitive files such as those containing API keys, database passwords, or private certificates must never be committed to a repository, even a private one, because leaked credentials are a serious security risk. A typical .gitignore entry looks like this:

# Ignore environment variable file containing secrets
.env

# Ignore Node.js dependencies folder
node_modules/

# Ignore compiled Python bytecode
__pycache__/
*.pyc

GitHub provides pre-made .gitignore templates for dozens of languages and frameworks, making it easy to start with sensible defaults.

Access permissions control what each collaborator can do with the repository. GitHub's permission model uses roles:

Role What They Can Do
Read View and clone the repository; open issues and discussions.
Triage Read access plus the ability to manage issues and pull requests without writing code.
Write Push branches, open pull requests, and merge approved changes.
Maintain Write access plus repository management tasks, excluding sensitive settings.
Admin Full control, including changing settings, managing permissions, and deleting the repository.

For most course projects, contributors are given Write access while the project owner retains Admin access.

Branching and Pull Requests

Branching is the mechanism that allows a team to develop multiple features, fix bugs, and experiment — all simultaneously — without any of that work interfering with the stable, deployable version of the project.

Imagine the project history as a timeline. The main branch (historically called master, now conventionally called main) represents that timeline's trunk. A golden rule of collaborative development is that the main branch should always contain code that works. It should be the version you would feel comfortable showing to a user or deploying to a server at any moment. Work in progress, experiments, and unreviewed code should never live directly on main.

When a developer starts working on a new feature or bug fix, they create a feature branch. This branch is a diverging copy of main at that moment in time. All commits for the new work happen on this branch, completely isolated from main and from any other branches being developed simultaneously. A typical branching workflow looks like this:

# Start from an up-to-date main branch
git checkout main
git pull origin main

# Create and switch to a new feature branch
git checkout -b feature/user-authentication

# ... make changes, then stage and commit them ...
git add .
git commit -m "Add login form and session handling"

# Push the feature branch to GitHub
git push origin feature/user-authentication

Branch names should be short and descriptive. Common conventions include prefixes like feature/, bugfix/, or hotfix/ to immediately communicate the branch's purpose.

Once the work on a feature branch is complete, the developer opens a pull request (PR) on GitHub. A pull request is a formal proposal to merge the changes from the feature branch into main. But it is much more than a merge button — it is a structured conversation about the code. Team members can:

  • Read a diff showing exactly which lines were added, modified, or deleted.
  • Leave inline comments on specific lines to ask questions or suggest improvements.
  • Request changes, requiring the author to revise the code before it can be merged.
  • Approve the pull request once they are satisfied with the changes.

This review process catches bugs, enforces coding standards, and spreads knowledge of the codebase across the team. No one person becomes the only one who understands a particular part of the system.

After the required number of approvals is received (teams often require at least one reviewer's approval), the pull request is merged. GitHub offers several merge strategies:

  • Merge commit: Creates a dedicated merge commit that records the integration of the two branches. Preserves the full history of the feature branch.
  • Squash and merge: Combines all commits from the feature branch into a single commit on main. Produces a cleaner, more readable history.
  • Rebase and merge: Replays the feature branch commits on top of main without a merge commit, creating a perfectly linear history.

After merging, the feature branch is typically deleted — it has served its purpose and the changes now live in main.

GitHub for Project Management

One of GitHub's most underappreciated strengths is how tightly its project management features connect to the actual code. Unlike standalone tools where task lists and code live in separate systems, GitHub keeps them in the same place, making it easy to trace every task back to the exact commits that completed it.

GitHub Issues are the fundamental unit of work tracking. An issue might describe a bug ("Login button unresponsive on mobile Safari"), a feature request ("Add dark mode support"), or a documentation task ("Write setup guide for Windows users"). Issues support:

  • Assignees: One or more team members responsible for resolving the issue.
  • Labels: Color-coded tags like bug, enhancement, help wanted, or custom labels specific to the project.
  • Linking to code: When a pull request includes the phrase Closes #42 in its description, GitHub automatically closes issue #42 when the pull request is merged. This creates a traceable link between the problem and its solution.

Project boards (via GitHub Projects) provide a visual workspace for managing issues and pull requests. The classic layout uses columns to represent workflow stages. A simple board might look like this:

To Do In Progress In Review Done
Set up database schema Build login form Add email validation Initialize repository
Write API endpoints Style navigation bar Create README

Cards on the board are linked directly to issues or pull requests, so moving a card from In Progress to Done is as meaningful as it looks — it reflects real work completed in the codebase. GitHub's newer Projects interface also supports a spreadsheet view, custom fields, and automated rules (for example, automatically moving a card to In Review when a pull request is opened).

Milestones allow teams to group related issues together under a shared goal and track collective progress toward that goal. For instance, a milestone called Version 1.0 Launch might contain fifteen issues covering everything needed for the first public release. GitHub displays a progress bar showing the percentage of those issues that have been closed, giving the whole team a clear sense of how close they are to the milestone's target date. Milestones are especially useful in course projects for mapping issues to sprint deadlines or graded deliverables.

Together — repositories, branches, pull requests, issues, project boards, and milestones — GitHub provides everything a team needs to plan, build, review, and ship software collaboratively. Learning to use these tools fluently is not just a technical skill; it is the foundation of how professional software teams operate.

NotesIntroduces GitHub as the central collaboration and code management platform for the course project. Students set up repositories, learn branching strategies, and understand how GitHub supports team workflows.