Introduction to Git and GitHub
Git remembers every version of your project on your computer. GitHub keeps a copy online so you can back it up, share it and work on it with other people.
On this page · 5 min · Beginner
On this page
- Learning objectives
- Explanation
- Step-by-step screens
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Beginner
- Updated
- Nov 25, 2026
Related tutorials
Learning objectives#
- Explain the difference between Git and GitHub
- Name the four places your changes live
- Know what a commit, a push and a pull do
- Understand why every developer is expected to know Git
Explanation#
Git is a version control system: a program on your computer that saves snapshots (commits) of your project. You can go back to any snapshot, see who changed what, and try ideas on separate branches without breaking the working version.
GitHub is a website that hosts Git repositories. It adds everything around the code: a web page for each project, pull requests for reviewing changes, issues for tasks, Actions for automation and Pages for free websites. GitLab and Bitbucket are similar sites; Git itself works the same with all of them.
A change travels through four places. You edit files in your working folder; git add puts the changes you want into the staging area; git commit saves them as a snapshot in your local repository; git push uploads new commits to GitHub. git pull does the opposite and brings other people’s commits down to you.
You do not need the command line for everything: VS Code, GitHub Desktop and the GitHub website can do most of it with buttons. Learning the few core commands still pays off, because every tool uses the same ideas.
Step-by-step screens#
Drawings of github.com, the Git installer, VS Code and a terminal. GitHub changes its layout from time to time; the button names stay the same. The red numbers match the numbered actions under each picture; names on your computer will differ.
Loading pictures…
Code example: The everyday cycle in five commands#
git clone https://github.com/asha/hello-github.git # copy a repository to your computer
cd hello-github
# ...edit index.html in VS Code...
git add index.html # 1. stage the change
git commit -m "Add a welcome line" # 2. save a snapshot
git push # 3. upload it to GitHub
git pull # 4. download changes made by others
[main 3f9c2a1] Add a welcome line 1 file changed, 1 insertion(+) To https://github.com/asha/hello-github.git 8d41e07..3f9c2a1 main -> main Already up to date.
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- git clone downloads the whole project, including its history.
- git add chooses which changes go into the next snapshot.
- git commit stores the snapshot locally with a message — nothing is online yet.
- git push sends your new commits to GitHub; git pull brings down everyone else’s.
Real-world use case#
A student keeps every college project on GitHub. When the laptop breaks, git clone restores everything on a new one in a minute — and recruiters can read the code and commit history.
Common mistakes#
Git runs on your computer and works offline. GitHub is one of several websites that host Git repositories.
A commit is only on your computer. Until you push, nobody else (and no backup) has it.
Best practices#
- Commit small, related changes with a clear message
- Push at least once a day
- Pull before you start working
- Keep one repository per project
Remember this#
Git = version history on your computer.
GitHub = the online home for Git repositories.
add → commit → push; pull to get others’ work.
Practice exercise#
Your task: Write the command that shows the history of commits in the current repository, one line per commit.
Show solution
git log --oneline
Mini quiz#
Which command uploads your commits to GitHub?
Want more? Practise all Git & GitHub MCQs · Git & GitHub interview questions
My notes#
Saved in this browser.