What is the difference between Git and GitHub?
Git is a version control tool that runs on your own computer and records the history of your code. GitHub is a website that hosts Git repositories online and adds collaboration features like pull requests, code review, issues and CI. You can use Git without GitHub, but GitHub is built on top of Git.
Explain it simply
Git is the tool. GitHub is a place to keep and share what the tool produces.
Git is a program you install on your laptop. It takes snapshots of your project (called commits), so you can see what changed, go back to an older version, and work on new features in separate branches without breaking the working code. All of this works offline.
GitHub is a website owned by Microsoft. It stores a copy of your Git repository on the internet so your team can pull it, push to it, review each other's changes and track bugs. GitLab, Bitbucket and Azure DevOps do the same job. They are all hosting services for Git repositories.
A simple comparison: Git is like the camera that takes photos, and GitHub is like Google Photos, where you upload them so others can see and comment.
Example
You can use Git alone, with no account anywhere:
mkdir notes-app && cd notes-app
git init
echo "# Notes App" > README.md
git add README.md
git commit -m "Add README"
git log --oneline3f2a9c1 (HEAD -> main) Add READMEOnly when you want to share it do you connect a remote on GitHub and push:
git remote add origin https://github.com/your-username/notes-app.git
git push -u origin mainHow it works
| Git | GitHub | |
|---|---|---|
| What it is | Command-line version control tool | Website and cloud service |
| Where it runs | Your computer | GitHub's servers |
| Needs internet | No | Yes |
| Made by | Linus Torvalds, 2005 | GitHub Inc., now part of Microsoft |
| Main features | Commits, branches, merges, history | Pull requests, issues, Actions (CI), Pages, forks |
Git is distributed. Every developer has the full history on their machine, not just the latest files. GitHub is simply one more copy that everyone agrees to treat as the shared one, usually called origin.
Real-world use
In most companies, both service and product, you write code locally, commit with Git, push to a shared remote (GitHub, GitLab or Bitbucket), and open a pull request for review. Recruiters also look at your GitHub profile, so a few well-documented projects with clean commit messages help in campus placements.
Common mistakes
- Saying "I committed to GitHub". You commit with Git on your machine, then push to GitHub.
- Thinking GitHub is required to use Git. It is not.
- Uploading files through the GitHub web page instead of learning
add,commitandpush. Interviewers notice. - Assuming GitHub is the only option. Many Indian IT companies use Bitbucket or Azure DevOps with the same Git commands.
What to say in the interview
"Git is a distributed version control system that runs locally. It tracks changes as commits, lets me create branches and merge them, and works offline. GitHub is a hosting platform for Git repositories. It adds collaboration on top, like pull requests, code reviews, issues and GitHub Actions for CI. So Git is the tool, and GitHub is one of the services where teams keep a shared copy. GitLab and Bitbucket are alternatives."
Follow-up questions
- What does "distributed" mean in a distributed version control system?
- What is the difference between
git fetchandgit pull? - What is a fork, and how is it different from a clone?
- What is
origin?
Go deeper
Read these once the basics above feel easy.
Older tools like SVN are centralised: there is one server with the history, and you check out only the current files. If the server is down, you cannot commit. With Git, every clone has the complete history, so you can commit, branch and view logs offline, and any clone can restore the repository if the server is lost.