So here's what happened...
I forked a project on GitHub because I wanted to contribute to one of its features.
But when I opened my fork - boom 💥 - only the main
branch was there. All the other branches from the original repo? Gone.
At first, I thought something went wrong with the fork. But nope - that’s just how GitHub works.
🤔 The Problem
When you fork a repo on GitHub, it only brings the default branch (usually main
or master
).
It does not copy over the other branches.
If the original repo had branches like:
feature/login
bugfix/style
refactor/api
You won’t see them in your fork.
But don't worry - they’re still there, just not in your copy… yet.
✅ The Solution
Here’s how I pulled the missing branches into my fork:
1. I added the original repo as a remote
git remote add upstream https://github.com/original-user/original-repo.git
Replace that URL with the actual repo you forked from.
2. Then I fetched all the branches from the original repo
git fetch upstream
Now I could see all the remote branches by running:
git branch -r
I saw branches like:
upstream/feature/login
upstream/bugfix/style
3. I checked out the one I wanted
Let’s say I needed the feature/login
branch:
git checkout -b feature/login upstream/feature/login
Boom - now I had that branch locally.
4. (Optional) I pushed it to my fork on GitHub
If I wanted to work on it and push it to my forked repo:
git push origin feature/login
Now it exists on my GitHub too.
🎉 Problem Solved!
So if you ever fork a repo and wonder,
"Where are the other branches?"
They’re not missing - you just need to fetch them manually.
Hope this helps someone out there! ✌️
#git #github #devto #webdev #beginners
Top comments (0)