Elena' s AI Blog

I have cloned my git repository and landed on main. How to get your branch

03 Oct 2025 (updated: 07 Nov 2026) / 8 minutes to read

Elena Daehnhardt

DALL·E / OpenAI’s image model inside ChatGPT 5.0: A flat-style digital illustration depicts a software developer transitioning from the 'main' branch to the 'dev' branch using the command ‘git fetch origin’, displayed in a clean, digital flat art style with a light beige background. The developer, depicted with black hair, glasses, and casual attire, steps from a dark grey platform labelled ‘main’ towards a glowing turquoise ‘dev’ platform, while a teleportation effect reinforces the shift between the two branches.

If you click an affiliate link and subsequently make a purchase, I will earn a small commission at no additional cost (you pay nothing extra). This is important for promoting tools I like and supporting my blogging.

I thoroughly check the affiliated products' functionality and use them myself to ensure high-quality content for my readers. Thank you very much for motivating me to write.



TL;DR:
  • A cheat sheet for navigating remote branches after a fresh clone. Learn why 'git fetch origin' is necessary and how to safely switch and stash branches.

📚 This post is part of the "Git Survival Guide" series

Series: Git Survival Guide (Part 18 of 34)

All 28 published parts

Previous: Part 13 — Git Failed to Push Some Refs

Next: Part 19 — Should you use rebase?

Fixing “Landed on Main”: How to Access Remote Git Branches After Cloning

Cloning a repository is exciting — new code, new adventure. But sometimes Git drops you straight onto main when you really wanted that shiny dev branch.

      Remote (origin)          Local
    ------------------      ------------
    origin/main             main  ← default after clone
    origin/dev      ---->   dev   ← your new branch

git clone is a Git command that downloads a repository’s full history but only fully maps and checks out the default branch, usually main or master; other remote branches exist in the history but are not yet registered locally. No worries. Here’s the quick rescue plan.

How to fetch the remote branches and switch to the one you wanted follows below.

Still in this guide

  • git fetch origin: Registering Remote Branches Locally
  • Git Branch Navigation Commands: switch, pull, stash Cheat Sheet
  • Summary: Git Fetch and Switch Workflow for Remote Branches
  • References

You've hit a Deep Dive tutorial.

I spend dozens of hours researching, coding, and breaking things to write these guides. This content is free, but reserved for my subscriber community. Drop your email below to unlock this guide (and all past/future deep dives):

Already a subscriber? Use the magic link from your last newsletter, or reset your password.

New subscribers get an inbox mail: Set a password to unlock articles. The form does not log you in — use the same email afterwards.

desktop bg dark

About Elena

Elena, a PhD in Computer Science, simplifies AI concepts and helps you use machine learning.




Citation
Elena Daehnhardt. (2025) 'I have cloned my git repository and landed on main. How to get your branch', daehnhardt.com, 03 October 2025. Available at: https://daehnhardt.com/blog/2025/10/03/i-have-cloned-my-git-repository-and-landed-on-main-how-to-get-your-branch/
All Posts