EasyConcept

What is Git and how is it different from GitHub?

Technology:
Git
Experience:
Intern,
Junior
Topics:
Git,
DevOps

Quick answer

Git is a distributed version control system that tracks changes to files on your machine; GitHub is a hosting service for Git repositories that adds collaboration features such as pull requests, code review and CI.

Detailed explanation

Git records snapshots of a project as commits. Every clone holds the full history, so you can commit, branch, view logs and compare versions without a network connection. Branches are cheap pointers to commits, which is what makes feature branches and experiments practical.

GitHub, GitLab and Bitbucket host a copy of the repository on a server so a team can share it. On top of Git they add pull requests, code review, issue tracking, permissions and automation such as GitHub Actions. You can use Git without GitHub, but not the other way round.

In day-to-day work you commit locally with Git, push your branch to the hosted remote, open a pull request for review, and merge it once checks pass.

Example

bash
git init                     # start tracking a project
git add src/app.js           # stage a change
git commit -m "Add login form"
git remote add origin https://github.com/you/project.git
git push -u origin main      # share it on GitHub

How to explain it in an interview

Git is the version control tool that runs locally and stores the full history in every clone. GitHub is a service that hosts Git repositories and adds pull requests, reviews, issues and CI on top. I use Git to commit and branch, and GitHub to share work and get it reviewed.

Key points

  • Git: the version control tool, works offline
  • GitHub: a hosting and collaboration platform for Git repositories
  • Every Git clone contains the full history

Common mistakes

  • Using "Git" and "GitHub" as the same thing.
  • Thinking you need an internet connection to commit. Commits are local until you push.

Follow-up questions

  • GitEasy

    What is the difference between git fetch and git pull?

    git fetch downloads new commits from the remote without changing your working branch; git pull runs a fetch and then merges (or rebases) those commits into your current branch.

    Intern 路 Junior 路 Git
  • GitMedium

    What is the difference between git merge and git rebase?

    Both integrate changes from one branch into another: merge keeps both histories and joins them with a merge commit, while rebase rewrites your commits so they appear on top of the target branch, giving a linear history.

    Junior 路 Mid-level 路 Git
  • GitMedium

    How do you resolve a merge conflict in Git?

    Open the conflicted files, decide what the final code should be between the conflict markers, remove the markers, run the tests, then stage the files and continue the merge or rebase.

    Junior 路 Mid-level 路 Git
  • GitMedium

    What is the difference between git reset and git revert?

    git revert creates a new commit that undoes an earlier one and is safe on shared branches; git reset moves the branch pointer back to an earlier commit, effectively removing later commits from that branch鈥檚 history.

    Mid-level 路 Senior 路 Git
  • Node.jsEasy

    What is the difference between package.json and package-lock.json?

    package.json lists your project's dependencies with allowed version ranges, while package-lock.json records the exact versions that were installed so every machine gets an identical dependency tree.

    Intern 路 Junior 路 Programming Fundamentals
  • DockerEasy

    What is the difference between a Docker container and a virtual machine?

    A virtual machine runs a full guest operating system on virtualised hardware, while a container shares the host鈥檚 kernel and isolates only the process, its filesystem and resources, which makes containers much lighter and faster to start.

    Intern 路 Junior 路 DevOps