Master Git — Just Like Understanding a Tree 🌳


BRANCH 🌿
🧠 What Is a Branch in Git?
🧠 What Is a Branch in Git? In Git, a branch is sort of like an alternate reality where you can go work on something new (a feature, a fix, or testing) without affecting the main project.
Think of Git like a tree:
The main trunk is the Main/Master branch (the stable, core version of your project).
The branches are like Feature or QA branches where different tasks grow.
This lets you experiment without harming the main tree.
🌳 Real-World Analogy: Tree and Branches
Imagine a fruit tree:
The main stem is the Main or Master branch.
Each branch is a feature or QA branch.
Branches come from the main trunk, but they grow in different directions with their own leaves.
Once a branch is ready, you merge it back to the main trunk.
Git Branch Tree Analogy
✍️ Rule of Thumb:
NEVER make changes directly in
main
ormaster
branch.
Always create a new branch (called a feature branch or sub-branch) for any new task or change.
🔧 Common Git Branch Commands
Purpose | Command |
Create and switch to a new branch | git checkout -b <branch-name> |
Switch to an existing branch | git checkout <branch-name> or git switch <branch-name> |
Delete a local branch | git branch -d <old-branch-name> |
Show remote branches | git branch -r |
Show all local and remote branches | git branch -a |
Show local branches only | git branch |
🔄 Types of Git Platforms (Where You Use Git Remotely)
Platform | What It Does |
GitHub | Most popular, cloud-based Git hosting service |
Bitbucket | Used by teams, supports Git and Mercurial |
GitLab | Git-based DevOps platform with CI/CD features |
🆚 Git CLI Has master
, GitHub Uses main
– What’s the Difference?
📜 Background:
Older versions of Git (especially on the command line) used
master
as the default branch name.GitHub now uses
main
as the default name for new repositories to follow more inclusive naming practices.
✅ Functionally the Same:
master
andmain
are just names. Both work exactly the same.If you clone a repo and see
main
, it's just the modern default.
🔁 Rename master
to main
(if needed):
branch -m master main # Rename locally
git push -u origin main # Push new main branch
git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
💡 You might also need to update the default branch settings in GitHub if you rename it.
Subscribe to my newsletter
Read articles from ABHISHEK WAGHMARE directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

ABHISHEK WAGHMARE
ABHISHEK WAGHMARE
An Introduction To DevOps: Where Development And Operations Meet 🔍 My DevOps learner journey has been inspired by a true passion for continual personal development and a genuine curiosity for cloud and automation technologies. With the practice of engaging in numerous online coursework and community threads, I have built a growing comprehension of what is necessary for everyday life in the tools offered from Docker, Jenkins, and Kubernetes, which are mandatories in the IT Society. 🛠 What sets me apart? A commitment to practical application. Through personal projects, I actively implement my learning to solve real-world problems, gaining hands-on experience. This proactive approach helps me not only understand technologies at a surface level but to deeply integrate them into effective solutions. My ultimate goal? To merge innovative DevOps practices with business objectives to streamline operations and boost productivity in any tech landscape. I am eager to bring my fresh perspective and evolving expertise to a vibrant team, where continuous learning is intertwined with company growth. 📨 Let’s connect and explore how we can drive progress together in the fascinating world of DevOps!