What is a GitHub repository and how does it differ from a local Git repository?
Quick Answer
A GitHub repository is a cloud-hosted Git repository that adds collaboration features like pull requests, issues, access control, and webhooks on top of the standard Git version control system. A local Git repo lives only on your machine, while a GitHub repo serves as the shared remote that teams push to and pull from.
Detailed Answer
Think of a local Git repository as your personal notebook where you draft ideas, and a GitHub repository as the shared whiteboard in the office where the whole team sees the final version. You scribble in your notebook (commit locally), then pin your best pages to the whiteboard (push to GitHub) for everyone to review and build upon.
A Git repository at its core is a directory containing a .git folder that tracks every change to your files through commits, branches, and tags. Git is a distributed version control system, meaning every developer has a complete copy of the project history. GitHub is a cloud platform that hosts Git repositories and layers on features that Git alone does not provide: browser-based code review through pull requests, issue tracking with labels and milestones, team-based access control through organizations, automated CI/CD via GitHub Actions, and integrations with hundreds of third-party tools through webhooks and the GitHub API.
Internally, when you create a repository on GitHub, the platform initializes a bare Git repository on its servers. A bare repository has no working directory, only the .git database of objects (blobs, trees, commits, and tags). When you run git push, your local Git client communicates with GitHub over HTTPS or SSH, transferring only the objects the remote does not already have through a process called packfile negotiation. GitHub then updates its references (branches and tags) and fires any configured webhooks to notify external systems like Slack channels or CI pipelines. The GitHub web interface reads from this bare repository to render file trees, diffs, and commit histories in the browser.
In production environments, teams typically create repositories under a GitHub Organization rather than personal accounts. This enables centralized billing, team-based permissions (read, triage, write, maintain, admin), branch protection rules that prevent direct pushes to main, required status checks from CI systems, and CODEOWNERS files that automatically request reviews from the right teams. A microservices company might have repositories like payments-api, user-auth-service, and checkout-worker, each with their own branch protection rules and deployment pipelines. The organization acts as the governance layer that personal accounts lack.
A common gotcha for beginners is confusing Git with GitHub. Git is the open-source version control tool created by Linus Torvalds in 2005. GitHub is a commercial platform (owned by Microsoft since 2018) that hosts Git repositories. You can use Git without GitHub (using GitLab, Bitbucket, or your own server), and understanding this distinction is important because interviewers want to know you grasp the underlying technology, not just the platform.