To switch between branches on GitHub, click the branch dropdown on your repository page (it shows your current branch name, usually "main"), and select the branch you want to view. The file list and all file contents update instantly to show that branch's version. You can also type in the search field to quickly find a branch by name. Switching branches does not change or delete anything — it just changes which version you are looking at.
Navigating Between Branches on GitHub
Branches are parallel versions of your project that can have different files and different code. When you look at a repository on GitHub, you are always viewing one specific branch at a time. The branch dropdown near the top-left of the file list tells you which branch you are on. Switching branches changes everything you see — the file list, file contents, and commit history all update to reflect the selected branch. This is like flipping between different drafts of a document. Switching does not modify anything; it simply changes your view. If you are collaborating with a team or using AI tools like Cursor that create branches for different features, knowing how to switch between branches lets you review work in progress, check what changed, and verify code before merging. You can also compare branches to see exactly what is different between them.
Prerequisites
- A free GitHub account (sign up at github.com)
- A repository with at least two branches (see our branch creation tutorial)
Step-by-step guide
Locate the branch dropdown on your repository page
Locate the branch dropdown on your repository page
Go to your repository on github.com. Near the top-left of the page, above the file list, you will see a dropdown button. It shows the name of the branch you are currently viewing — usually "main" if you have not switched. This dropdown is your branch navigator. It may also show a branch icon (a line splitting into two) next to the name.
Expected result: You can see the branch dropdown button showing your current branch name (e.g., "main").
Click the branch dropdown to see all branches
Click the branch dropdown to see all branches
Click the dropdown button. A panel opens showing two tabs: "Branches" and "Tags." Stay on the Branches tab. You will see a list of all branches in the repository. The currently active branch has a checkmark next to it. At the top there is a search field where you can type to filter branches by name.
Expected result: You see a list of all branches with a checkmark next to the currently active one.
Click the branch you want to switch to
Click the branch you want to switch to
Click on the name of the branch you want to view. GitHub instantly updates the page: the dropdown now shows the new branch name, and the file list updates to show the files as they exist on that branch. You may notice files that are different from main — some might be new, some might be missing, and some might have different content.
Expected result: The branch dropdown shows the new branch name, and the file list reflects that branch's contents.
Verify you are on the correct branch
Verify you are on the correct branch
Look at the branch dropdown to confirm it shows the expected branch name. You can click on any file to see its content on this branch. If a file was edited on this branch, the changes are visible here. To go back to main, click the dropdown again and select "main."
Expected result: The branch name in the dropdown matches the branch you selected, and file contents reflect that branch's versions.
Compare branches to see differences (optional)
Compare branches to see differences (optional)
To see exactly what is different between two branches, click the "X branches" link near the top of the repository page (next to the commits and tags counts). On the branches page, find your branch and click "New pull request" next to it. GitHub shows a comparison view (a "diff") highlighting every line that was added (green), removed (red), or changed between the two branches. You do not have to create the pull request — you can just view the comparison and close the tab.
Expected result: You see a side-by-side or unified diff showing every change between the two branches.
Complete working example
1# Active Branches23This document tracks active branches in the project.45## Current Branches67| Branch | Purpose | Owner | Status |8|--------|---------|-------|--------|9| main | Production code | Team | Active |10| feature/pricing-page | New pricing section | Alex | In progress |11| fix/mobile-nav | Fix hamburger menu | Sam | Ready for review |12| update/hero-section | Redesign hero area | Jordan | In progress |1314## How to Switch Branches15161. Go to the repository page on GitHub172. Click the branch dropdown (top-left, shows current branch)183. Select the branch you want to view194. Verify the dropdown shows the new branch name2021## Branch Rules2223- Never push directly to main24- Create a pull request to merge25- Delete branches after mergingCommon mistakes when switchhing Between Branches in GitHub
Why it's a problem: Editing a file while on the wrong branch
How to avoid: Always check the branch dropdown before clicking the pencil icon. If it shows the wrong branch, switch to the correct one first.
Why it's a problem: Thinking switching branches deletes or changes files
How to avoid: Switching is just changing your view — like changing TV channels. Nothing is created, modified, or deleted when you switch.
Why it's a problem: Not knowing which branch you are on and committing to the wrong one
How to avoid: Make it a habit to glance at the branch dropdown every time you start editing. The branch name is visible in the top-left area.
Why it's a problem: Confusing branch switching with merging
How to avoid: Switching lets you view a branch. Merging combines changes from one branch into another. They are completely different actions.
Best practices
- Always check which branch you are on before making any edits.
- Use the search field in the branch dropdown to quickly find branches in large repositories.
- Use the compare view to review changes before merging a branch into main.
- Bookmark frequently used branch URLs if you switch between them often.
- After reviewing a branch, switch back to main so you do not accidentally edit the wrong branch later.
- In github.dev (press .), use the branch indicator in the bottom-left corner of the editor to switch branches.
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
Explain GitHub branches to me like I am a non-technical founder. How do I view different branches in my repository and understand what changed between them?
Frequently asked questions
Does switching branches affect my live site or deployed app?
No. Switching branches on GitHub only changes what you see in the browser. Your deployed app or connected services (like Lovable or Vercel) are tied to a specific branch, usually main. Switching your view does not change what is deployed.
Can I view two branches side by side?
GitHub does not show two branches simultaneously in the file browser. However, you can use the compare view (github.com/user/repo/compare/main...branch-name) to see a diff of all changes between two branches.
How do I know what changes were made on a branch?
Switch to the branch and click the commits link (e.g., "3 commits ahead of main") near the top. This shows all commits made on the branch. You can also use the compare view for a full diff.
Will switching branches in the browser affect my Cursor or Replit project?
No. Switching branches on GitHub only changes your browser view. Your Cursor workspace or Replit project has its own branch context. In Cursor, use the Source Control panel to switch branches locally.
What if the branch I am looking for is not in the dropdown?
It may have been deleted or merged. Check the branch page (click the "X branches" link) and look under the "All" or "Stale" tabs. You can also search for it in the dropdown search field.
Can RapidDev help me understand what changed on a branch?
Yes. RapidDev helps non-technical founders review branch changes, understand diffs, and make informed decisions about what to merge into their production code.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation