You know that sinking feeling when you delete the wrong file? Or when you're trying to merge your teammate's code and suddenly everything's red and broken? Yeah, Git won't prevent those moments, but it'll definitely save you from them.
I used to think Git was just something you grudgingly learned because everyone else used it. Then I actually started using it properly, and honestly? It changed everything. Suddenly I could experiment without fear, collaborate without chaos, and actually understand what happened to my code last time.
This isn't going to be one of those boring Git tutorials that dumps 50 commands on you. Instead, we're covering the essentials: the commands you'll actually use daily, explained in plain English. Whether you're brand new to Git or you've been faking it with the same three commands for years, let's get you comfortable with version control.
So let's start with the basics, the commands that'll become muscle memory.
1.git init
This is how you tell Git "hey, start tracking this project." Run it once in your project folder and Git creates a hidden .git directory where it stores all your version history.
mkdir myApp
cd myApp
git init
Now your folder is a Git repository. That's it.
2.git add
Stages changes in the current directory and sub directories.
Think of this as preparing your changes for a snapshot. You're telling Git "these are the files I want to include in my next commit." Nothing's permanent yet, you're just staging things.
echo "# My firs App" > README.md
echo "Demo" >> README.md
git add README.md
Pro tip: Use
git add .to stage everything at once, but be careful; you might accidentally include files you didn't mean to (like thatsecrets.envfile you forgot about).
3.git commit
Now you're taking the snapshot. This saves all your staged changes with a message describing what you did. Think of commits like save points in a video game; you'll thank yourself later when you need to roll back.
git add README.md
git commit -m "Initial commit
The -m flag lets you add your message right in the command. Keep it short and descriptive: "Initial commit", "Fix login bug", "Add user dashboard", etc.
4.git push
You've made commits locally, but now you need to send them to GitHub (or wherever your remote repository lives). That's what push does, it uploads your local changes to the cloud.
git add .
git commit -m "feat: add a new feature"
git push
First time pushing to a new branch? Git will probably yell at you and tell you to use git push -u origin branch-name. Just do what it says, the -u sets up tracking so future pushes are easier.
5.git pull
Your teammate just pushed changes. Before you start working, you need to grab their updates and merge them into your local code. That's git pull, it downloads changes and automatically merges them.
git status
git pull origin main
git log --oneline
Warning: If you have uncommitted changes and you pull, Git might complain about conflicts. Commit or stash your work first to avoid headaches.
6.git remote
This connects your local repository to a remote one (like on GitHub). You'll usually do this once when setting up a project.
git remote add origin <url>
git remote -v
git remote rename origin myFirstApp
The origin name is just a convention: it's the default name for your main remote repository. You can call it whatever you want, but everyone uses origin so... just stick with that.
7.git branch
Branches let you work on features without touching your main code. Think of them as parallel universes for your project — experiment freely, then merge back when you're ready.
git branch
git branch feature-UI-layout
git branch
The first git branch lists all branches. The second creates a new one. The third confirms it was created. You're still on your original branch though — creating doesn't switch you to it.
8.git fetch
This downloads changes from the remote repository but doesn't merge them into your code. It's like checking what's new without actually integrating it yet.
git fetch origin
When to use it: When you want to see what others have done before deciding to merge. It's the cautious version of
git pull.
9.git checkout
Switches you between branches. It's how you move from one parallel universe to another.
git branch
git checkout feature-UI-layout
git branch
You'll see an asterisk (*) next to the branch you're currently on. Modern Git also has git switch which does the same thing but is more explicit.
10.git merge
You finished your feature branch and now you want to bring those changes back into main. That's what merge does, it combines the histories of two branches.
git checkout main
git merge feature-UI-layout
git log --oneline
Merge conflicts are normal. When Git can't figure out how to combine changes automatically, it asks you to decide. Don't panic: just open the files, pick which changes to keep, and commit the result.
11.git status
Your best friend when you're confused. It shows what files have changed, what's staged, what's not, and which branch you're on.
git status
echo "Happy learning git" >> hello.txt
git status
Run this constantly. Seriously. Before commits, after pulls, when things feel weird — git status is your diagnostic tool.
12.git reset
Made a mistake? git reset lets you undo commits and move your branch pointer back in time. Be careful with this one.
git log --oneline
git reset --hard <commit-hash>
git status
The --hard flag is dangerous — it deletes your changes permanently. Use --soft if you want to keep the changes but undo the commit. And if you've already pushed, don't reset — use git revert instead.
Conclusion
These twelve commands will cover 90% of your daily Git usage. You don't need to memorize every flag or option, just understand what each command does and why you'd use it.
Git gets easier the more you use it. Yeah, you'll mess up sometimes (we all have). But that's fine, Git is designed to handle mistakes. Just keep committing, keep experimenting, and don't be afraid to Google when things get weird. Want to level up your Git skills? Try this interactive practice tool here.
Now go forth and version control with confidence. You've got this.
Top comments (0)