/github-for-non-tech

How to switch between branches in GitHub?

Switch branches in GitHub with ease. Our guide covers installing Git, cloning repositories, listing branches, switching or creating new ones, and pushing to remote.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to switch between branches in GitHub?

 
Step 1: Install and Configure Git
 

Before you can switch branches, make sure Git is installed and configured on your machine.

  • Check if Git is installed
  • Set your username and email for commits
git --version
git config --global user.name "Your Name"
git config --global user.email "[email protected]"

 
Step 2: Clone the Remote Repository
 

If you don’t have the repository locally, clone it from GitHub:

  • Use the repository’s HTTPS or SSH URL
  • Enter the command in your terminal
git clone https://github.com/username/repository.git
cd repository

 
Step 3: View Your Current Branch
 

Check which branch you’re on right now:

  • This command highlights the active branch with an asterisk (\*)
git branch

 
Step 4: List All Local and Remote Branches
 

See every branch available locally and on the remote:

  • -a stands for “all”
git branch -a

 
Step 5: Switch to an Existing Local Branch
 

Use either git switch (newer) or git checkout (older).

  • Replace branch-name with the branch you want
# Using the newer command
git switch branch-name

# Or using the classic command
git checkout branch-name

 
Step 6: Create and Switch to a New Branch
 

If the branch doesn’t exist yet, create it and switch in one step:

  • -c creates a branch with git switch
  • -b creates a branch with git checkout
# New switch syntax
git switch -c new-branch-name

# Classic checkout syntax
git checkout -b new-branch-name

 
Step 7: Push the New Branch to GitHub
 

After creating a branch, push it to the remote so others can see it:

  • -u origin sets the upstream tracking
git push -u origin new-branch-name

 
Step 8: Confirm the Switch on GitHub Web
 

Go to GitHub.com, navigate to your repository, click the “Branch” dropdown, and select your branch to confirm you’ve switched correctly.

 

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022