Git vs. GitHub: What’s the Difference?
Git and GitHub are closely related, but they are not the same thing. Git is version control software that tracks changes to files. GitHub is an online platform for hosting Git repositories and collaborating on them. This guide explains what each tool does and how to use them together.
Practice Git workflows →The short answer
- Git is a distributed version control system. It records project history and lets you work with commits and branches on your computer.
- GitHub is a web-based service that hosts Git repositories and provides collaboration features such as pull requests, issues, and code review.
- You can use Git without GitHub, and you can use GitHub because Git tracks the repository’s changes.
What is Git?
Git is software you install and run locally (or on a server) to manage a project’s history. It records snapshots called commits, allows you to create branches for separate lines of work, and helps you compare or combine changes. A Git repository contains the project files and the history Git has recorded for them.
Basic Git commands work in a terminal and do not require an internet connection for local operations:
git init
git add .
git commit -m "Add project files"
git log --onelineThese commands create a repository, stage and commit files, then display recorded commits. Git’s history stays on your machine until you connect and share it with a remote.
What is GitHub?
GitHub is a hosted service for Git repositories. It stores a remote copy of a repository so you and collaborators can access it online. The GitHub website also adds tools around that repository: pull requests for proposing changes, issues for tracking work, code reviews, permissions, and automation.
GitHub is one Git hosting service, not Git itself. Other services also host Git repositories, and teams can run their own Git servers. The Git commands used to commit, branch, and inspect history remain Git commands regardless of where a remote repository is hosted.
How Git and GitHub work together
A common workflow is to make and commit changes locally with Git, then push those commits to a GitHub repository. To get teammates’ changes, fetch or pull from the remote. Here is a simplified example after creating a repository on GitHub and connecting it as origin:
git add .
git commit -m "Build the homepage"
git push -u origin mainGit creates the commit; git push sends it to the remote repository hosted on GitHub. The command-line tool is Git, while the remote service in this example is GitHub. For a new project, first create or choose a GitHub repository and connect it as a remote; otherwise, there is nowhere for git push to send the commits.
Git vs. GitHub at a glance
| Question | Git | GitHub |
|---|---|---|
| What is it? | Version control software | A hosted code collaboration platform |
| Where does it run? | On your computer or a server | Online, with Git tools connecting to it |
| Can it work alone? | Yes, for local version control | It hosts Git repositories and adds collaboration tools |
Do you need GitHub to use Git?
No. Git can track changes, branches, and commits entirely on your computer. GitHub becomes useful when you want an online backup, access from multiple devices, or a place to collaborate. You can connect a local repository to GitHub later without changing what Git is or how local commits work.
Frequently asked questions
Is GitHub the same as Git?
No. Git is version control software; GitHub is a service that hosts Git repositories and supports collaboration around them.
Do I need to install GitHub?
GitHub is primarily an online service you access in a browser. To work with its repositories from a terminal, install Git and authenticate with GitHub using a supported method.