Getting Started with Git: 5 Essential Commands for Beginners
A beginner-friendly introduction to Git commands you'll use every day.
Are you new to Git and version control? Don’t worry, here’s a quick overview of the 5 basic commands that'll get you started in no time. I wrote this guide based on how I personally began working with Git on Windows.
Before we dive into Git commands, let’s take a quick look at what is git.
🔎What is git?
If you’ve ever worked on a coding project and wanted a way to “go back” after a mistake — that’s exactly what Git is for.
Git is a version control system that helps you keep track of changes in your code. You can save progress, roll back when things go wrong, and collaborate with others without stepping on each other’s toes.
It’s like having a magical undo button for your entire project history.
So, now that you know what Git is and why is it useful,
let’s walk through five essential commands to help you start using it right away.
For this walkthrough, I’ll be using a test folder named “git-test”,
just to keep things clean while testing Git basics 🐹
git init
Initializes a new Git repository in your current folder.
git init
Use this when starting a new project. It creates a hidden .git directory that tracks your changes.
git status
Shows which files are staged, unstaged, or untracked.
git status
Use this often to keep track of what’s going on before committing changes.
At this point, Git sees that there’s a file in the folder (
notes.txt
),
but it’s not being tracked yet — it’s completely new to Git.That’s why it shows up as “Untracked files” in red.
We’ll need to explicitly add it if we want Git to include it in version control.
We’ll take another look at
git status
in the next step to check what changed after staging the file.git add
Stages your changes to be committed.
git add filename.txt
or to stage every file in the directory, you can use:
git add .
Once you run
git add
, the file moves into the staging area,
meaning Git is now preparing to include it in the next commit.You’ll see the file listed under “Changes to be committed”, which indicates it’s ready to be saved with
git commit
.git commit
Saves your staged changes to the repository with a message.
git commit -m "Initial commit"
This shows a successful initial commit. Git records the commit with a unique hash and summarizes the change — in this case, one file notes.txt was added.
Good commit messages are short but descriptive!
After the commit,
git status
tells us that everything is up to date — there are no staged or unstaged changes, and the working directory is clean.git log
Shows the commit history of your repository.
git log
This shows the full commit history, including the commit hash, author, date, and message.
It’s useful for tracking what’s been done and by whom in detail.This displays a simplified, one-line version of the commit history.
It’s great for getting a quick overview of recent commits.
That’s it for the basics! 👍
In a future post, I’ll cover git branch, git checkout, and git merge.