
Git 101: Version Control from Zero
January 22, 2026 · 9 min read
Series · part 1 of 1
Programming 101
- 1. Git 101: Version Control from Zero ← you are here
Difficulty
BeginnerTime to complete
30 minutes
Before you start
- ☐ Any device
- ☐ Not being scared of the terminal (you'll type maybe 15 commands)
- ☐ A GitHub account, or an email to make one with
Overview
If you already know what Git is and just want to type commands, skip to Installing Git. There's also a cheat sheet at the end.
What is version control?
Version control is a system that records changes to files over time, so you can go back and look at (or restore) a specific version later.
It lets you:
- Track the history of your code: who changed what, and when.
- Collaborate without overwriting each other's work.
- Go back to an earlier version when something breaks.
- Work in parallel on the same project, using branches.
And what happens if your code has no version control?
- It's hard to tell who changed what, and when.
- You lose progress when two people's changes overlap by accident.
- There's no history to fall back on as a backup.
If you've ever had a folder full of final.zip, final-2.zip and
final-REAL-fix.zip, you've done version control by hand. It doesn't scale.
Types of version control
There are three broad kinds:
| Type | How it works | Examples |
|---|---|---|
| Local VCS | Keeps the version history on a single computer. | RCS |
| Centralized VCS | One main server stores every version; clients check files out from it. | SVN, CVS |
| Distributed VCS | Every user has a full copy of the repository, history included. | Git, Mercurial |

Figure 1. Centralized (one shared repository everyone talks to) vs. distributed (everyone has their own repository and they push/pull between each other).
The big win of the distributed model: if the server disappears, every developer still has the whole project and its full history.
What is Git?
Git is a distributed version control system, created by Linus Torvalds (the creator of the Linux kernel) to manage Linux's code together with its community.
Why it's the one everyone uses:
- It works offline or online. Uploading to a server is optional.
- Branching and merging are cheap, fast and easy to understand.
- A huge community and integration with big platforms like GitHub, GitLab and Bitbucket.

Figure 2. A sneak peek of where we're going: fork → clone → commit → push → pull request → merged.
Installing Git
Install it
| OS | How |
|---|---|
| macOS | brew install git |
| Linux (Ubuntu) | sudo apt install git |
| Windows | Download the installer from git-scm.com/downloads |
Check that it worked
Open a terminal (Command Prompt / PowerShell on Windows) and run:
bash
git --version
If you get something like git version 2.x.x, you're good.
Tell Git who you are
Every commit is stamped with a name and email, so set them once:
bash
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Use the same email as your GitHub account, so GitHub can link your commits to your profile.
Repositories
A repository (repo) is a folder where Git tracks changes. Any folder can become one:
bash
cd my-project
git init
Git then creates a hidden .git/ folder inside it, which stores:
- the whole version history (commits, branches), and
- configuration and metadata.
If you can see a .git folder (turn on "show hidden files"), the
initialisation worked. You can also check with:
bash
git status
which shows the state of the local repository in that folder. Don't touch the
.git folder by hand; let Git manage it. Deleting it deletes your history.

Figure 3. Your files live next to the .git folder, which holds Git's own files and directories.
There are two kinds of repository:
- Local repository: stored on your own laptop/PC.
- Remote repository: hosted on a server (GitHub, GitLab, Bitbucket…).
A remote repository is what lets several people collaborate: each person works in their own local repository, and changes from everyone get combined on the remote.
The three areas: working directory, staging, repository
Once you've initialised (or cloned) a repository, you're working with three areas:

Figure 4. Files move from the working directory, to the staging area, to the repository.
Working directory: Your actual project files. This is where you edit and add code.
Staging area (index): A snapshot of the files that will go into your next commit. You add
files here with git add.
Repository (history): The database of every commit you've made. Git keeps the project's history here and tracks every change made to your files.
So the everyday loop is:
- Change files in the working directory.
- Add the changes to the staging area with
git add. - Save them into the repository with
git commit.
Your first commit
Let's do the loop for real. Start in a folder that isn't a repository yet:
bash
$ git status
fatal: not a git repository (or any of the parent directories): .git
That's expected. Initialise it:
bash
$ git init
Initialized empty Git repository in /home/you/example-repo/.git/
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
config/
fonts
images/
git status sorts files into two groups you'll see all the time:
- Untracked files: new files Git has never seen. They haven't been added to the staging area.
- Changes not staged for commit: files Git already tracks that you've modified, but haven't staged yet.
Stage your files
bash
git add <file> # stage one file
git add . # stage everything in this folder
. means "the current directory", so it covers ./test.txt, ./main.py and
everything else in it.
bash
$ git add .
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: config/X11/Xresources
new file: config/X11/xinitrc
new file: config/git/config
...
Commit
Staged files aren't saved in history yet. A commit takes a snapshot of the staged changes and stores it in the repository. No commit, no history.
bash
$ git commit -m "first snapshot commit"
[master (root-commit) 1f83680] first snapshot commit
139 files changed, 28782 insertions(+)
create mode 100644 config/X11/Xresources
...
-m is the message flag. Write something that tells future-you what this
snapshot is about.
Look at your history
bash
$ git status
On branch master
nothing to commit, working tree clean
$ git log
commit 1f83680f62aa3441170f86ef5570a354dee9be0a (HEAD -> master)
Author: Your Name <[email protected]>
Date: Thu Oct 23 17:52:23 2025 +0700
first snapshot commit
Congrats, that's local version control with Git. 🎉
Putting it on GitHub
Everything so far lives only on your machine. To back it up online (and to collaborate), connect your local repository to a remote one.
Create a new repository
Click New next to Top repositories on your dashboard.

Figure 5. The New button.
Then fill in the form:
- Repository name: anything you like. It doesn't have to match your local folder name.
- Visibility: Public means everyone can see your code. Private means only you (and people you invite) can. Private repos have a few restrictions, but that's a topic for later.
- Leave README, .gitignore and license off, since we already have a local repository with commits.

Figure 6. Pick a name and visibility, then hit Create repository.
Copy the remote URL
The new, empty repo shows a Quick setup box with its URL, e.g.
https://github.com/<you>/namanya-bebas-sip.git. Copy it.

Figure 7. The remote URL, and the full list of commands if you ever get lost.
Add it as a remote
Back in your terminal:
bash
git remote add origin https://github.com/<you>/namanya-bebas-sip.git
The format is git remote add <remote name> <url>. origin is just a
nickname for that URL; it's the conventional name for "my main remote".
Push
Uploading commits is called pushing. The first time, Git doesn't know
which remote and branch to push to, so a plain git push complains:
bash
$ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
Just tell it, once:
bash
$ git push --set-upstream origin master
Enumerating objects: 166, done.
...
To https://github.com/<you>/namanya-bebas-sip.git
* [new branch] master -> master
branch 'master' set up to track 'origin/master'.
The format is git push --set-upstream <remote> <branch> (-u for
short). Your branch name is shown by git status. After this, plain
git push works.
Refresh the page on GitHub and your code is there, safely stored online.

Figure 8. The pushed repository on GitHub.
Cloning a repository
Sometimes you want to download someone else's code (or your own), because you want to:
- edit it or contribute to it,
- compile and run it yourself,
- keep a copy of it locally, or
- grab your own code on another computer.
You can clone it. On the repository's GitHub page, click Code and copy the URL, then:
bash
$ git clone https://github.com/Roblox/cube.git
Cloning into 'cube'...
remote: Enumerating objects: 217, done.
...
Resolving deltas: 100% (94/94), done.

Figure 9. The clone URL lives under the green Code button. Try it with the repository you just made!
How is that different from downloading a ZIP?
- A clone keeps every snapshot of the code; version control comes along with it.
- You can browse the history with Git.
- The whole thing stays under Git's control: you can commit, branch, pull and push.
bash
$ cd cube
$ git log
commit 96249b74d68df0753d2ca40f3bed48aa43fd670f (HEAD -> main, origin/main, origin/HEAD)
Author: Akash Garg <...>
Date: Mon Jul 21 23:16:45 2025 -0700
Update README.md (#78)
...
$ git status
On branch main
Your branch is up to date with 'origin/main'.
nothing to commit, working tree clean
That git log is the same history you'd see under Commits on the website.

Figure 10. Top: clone copies a remote repository to your computer. Bottom: to contribute to someone else's project, you usually fork it first, clone your fork, and pull updates from the original ('upstream').
Branches
Branches are the feature you'll lean on the most. Here's why.
Your program is done and has reached v1.0. Now you want to add a feature, which means changing code that's already stable. The new code is broken, so now your program is broken too. 😭
To avoid that, you make a new line of work, a branch, for your changes.

Figure 11. new_feature branches off master, gets its own commits, then merges back.
master/main: the main, production version. Stable, and what users get.new_feature: an experimental version. Unstable, for developers to shape. It can be merged back into the main branch later.
Create a branch
bash
$ git branch
* master
$ git checkout -b new-branch
Switched to a new branch 'new-branch'
$ git branch
master
* new-branch
$ git status
On branch new-branch
nothing to commit, working tree clean
git branchlists the branches. The*marks the one you're on.git checkout -b new-branchcreatesnew-branch(that's the-b) and switches to it (that'scheckout).
From now on, every change you commit lands on new-branch. master stays
untouched.
Commit and push the branch
Make some changes as usual, then add and commit:
bash
$ git add .
$ git commit -m "add makan-bang.py feature"
[new-branch 0c283a0] add makan-bang.py feature
2 files changed, 0 insertions(+), 0 deletions(-)
When pushing, set the upstream to the new branch:
bash
$ git push --set-upstream origin new-branch
...
To https://github.com/<you>/namanya-bebas-sip.git
* [new branch] new-branch -> new-branch
branch 'new-branch' set up to track 'origin/new-branch'.
GitHub will notice the newly pushed branch, and the branch picker now lists both.

Figure 12. GitHub's banner for the freshly pushed branch.

Figure 13. Switch between branches on the website.
Merge with a pull request
To combine new-branch into master on GitHub, you open a pull request
(PR). Click Compare & pull request, check that the base is master and
the compare branch is new-branch, give it a title, and create it.

Figure 14. Opening a pull request from new-branch into master.
Why bother with a pull request? Sounds like extra work! A PR is where the team reviews the code, leaves comments, and tracks the progress of the branch. You can see exactly what changed, line by line:

Figure 15. The Files changed tab of a PR from another project, showing the differences between branches.
When it's ready, click Merge pull request, then Confirm merge.

Figure 16. No conflicts, so it can be merged automatically.

Figure 17. Confirm the merge. GitHub then marks the PR as merged, and you can delete the branch.

Figure 18. master now has the branch's commits plus a merge commit.
Congrats, you've merged two branches into one! To get the merged result on your computer too:
bash
git checkout master
git pull
Cheat sheet
| Command | What it does |
|---|---|
git config --global user.name "…" | Set your name (once per computer) |
git config --global user.email "…" | Set your email (once per computer) |
git init | Turn the current folder into a repository |
git status | What's changed, what's staged, which branch |
git add <file> / git add . | Stage one file / everything |
git commit -m "message" | Save staged changes as a snapshot |
git log | Show the commit history |
git remote add origin <url> | Connect to a remote repository |
git push -u origin <branch> | First push of a branch (then just git push) |
git pull | Download and merge new commits from the remote |
git clone <url> | Copy a remote repository to your computer |
git branch | List branches |
git checkout -b <name> | Create a branch and switch to it |
git checkout <name> | Switch to an existing branch |
What's next
This is part one. Next up in the series:
- Branch management: merging locally, merge conflicts, deleting branches.
- Commit controls: undoing, amending and reverting commits.
- User interactions: working with other people on the same repository.
- Community contribution: forks and contributing to open source.
続く. To be continued!
On this page
- Overview
- What is version control?
- Types of version control
- What is Git?
- Installing Git
- Repositories
- The three areas: working directory, staging, repository
- Your first commit
- Stage your files
- Commit
- Look at your history
- Putting it on GitHub
- Cloning a repository
- How is that different from downloading a ZIP?
- Branches
- Create a branch
- Commit and push the branch
- Merge with a pull request
- Cheat sheet
- What's next