Published , Last updated
I still remember the first time I ran git init—I was following a tutorial without fully understanding what Git was. Like many beginners, I made mistakes, got confused, and even lost a project or two along the way. But over time, Git became an essential part of my development workflow. Today, I can’t imagine building software—alone or with a team—without it.
This post isn’t just another Git tutorial. It’s a structured guide to help you grow with Git, from the basics to more advanced workflows, no matter where you are on your developer journey.
Git is a distributed version control system. In plain English: it tracks changes in your code so you can collaborate, revert, and manage your project’s history like a pro.
When I first heard of Git, I thought it was just for big teams. But even in solo projects, Git has saved me from losing weeks of work or tracking bugs through messy folders named project_final_really_final
.
Here’s what every beginner should start with:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Task | Command |
---|---|
Start a repo | git init |
Clone a repo | git clone URL |
Check status | git status |
Stage files | git add . |
Commit changes | git commit -m "message" |
View history | git log |
See changes | git diff |
When I started working on real projects, branching became essential. Instead of one chaotic main branch, I could isolate features and fixes.
main
stays clean. Work happens in feature/my-awesome-feature
.main
with small, frequent commits.
git checkout -b feature/login-page
Switch back to main:
git checkout main
PRs are more than a merge button. They’re about collaboration and accountability.
When I first joined a team, I was nervous about PRs. But I quickly learned they improve code quality, catch bugs early, and foster learning.
GitHub Flow:
If no other changes occurred on main
:
git merge feature/login
--no-ff
)Keeps merge commit for history:
git merge --no-ff feature/login
Makes commit history cleaner:
git checkout feature/login
git rebase main
⚠️ Don’t rebase shared branches unless you’re sure what you're doing!
Edit commit history:
git rebase -i HEAD~5
You can:
Apply a commit from one branch to another:
git cherry-pick <commit-hash>
Find the commit that introduced a bug:
git bisect start
git bisect bad
git bisect good <commit>
It will guide you commit-by-commit to the problem.
Here’s what I use daily on production teams:
main
main
before merging to avoid conflicts
.gitignore
to prevent committing secrets/logsfix: login bug
)git pull --rebase
to stay updated.gitconfig
Example:
git config --global alias.lg "log --oneline --graph --all"
Issue | Solution |
---|---|
Stuck merge | git merge --abort |
Undo last commit | git reset --soft HEAD~1 |
Delete local branch | git branch -d branch-name |
Delete remote branch | git push origin --delete branch-name |
Unstage file | git reset file.txt |
Restore file | git checkout HEAD -- file.txt |
Git can be overwhelming at first. But once you embrace it, it becomes a superpower. I’ve lost count of how many mistakes Git has saved me from — and how many teammates I’ve helped because I knew my way around it.
Whether you’re building side projects or deploying at scale, mastering Git isn't optional — it’s foundational.