/github-for-non-tech

How to understand what a branch is in GitHub?

Understand Git branches on GitHub with our step-by-step guide on creating, switching, merging, and deleting branches for efficient development.

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 understand what a branch is in GitHub?

 
Step 1. Understanding the concept of a branch
 

A branch in Git is a lightweight movable pointer to one of these commits. Think of branches as separate lines of development:

  • Each branch has its own history and can diverge from the main timeline.
  • Branches allow you to work on features, bug fixes, or experiments in isolation.
  • When you’re ready, you can merge your branch back into another branch (often the main branch).

 
Step 2. Viewing branches in a cloned repository
 

First, clone a repository (if you haven’t already) and navigate into it. Then list all local branches:


git clone https://github.com/USERNAME/REPO.git
cd REPO
git branch

You’ll see an asterisk (\*) next to the current branch, usually main or master.

 
Step 3. Inspecting remote branches
 

To see branches that exist on the remote (GitHub) as well as local ones:


git fetch
git branch -a
  • remotes/origin/main is the default remote branch.
  • Other remotes/origin/feature-xyz branches represent work in progress on GitHub.

 
Step 4. Creating a new branch
 

Create a branch to start working on a new feature without affecting main:


git checkout -b feature/login-form
  • This creates and checks out feature/login-form in one command.
  • Your working directory is now pointing at the tip of that new branch.

 
Step 5. Pushing your branch to GitHub
 

After committing your changes locally, push the branch to the remote so others can see it:


git push -u origin feature/login-form
  • -u origin feature/login-form sets up tracking so future pushes can use git push directly.
  • You’ll now see your branch on GitHub under “Branches.”

 
Step 6. Switching between branches
 

To switch from one branch to another:


git checkout main
git pull
git checkout feature/login-form
  • Always pull the latest changes on main before switching back.
  • git checkout updates your working files to match the branch you switch to.

 
Step 7. Merging a branch back into main
 

Once your feature is complete and tested, merge it into main:


git checkout main
git pull
git merge feature/login-form
  • If there are merge conflicts, Git will prompt you to resolve them before completing the merge.
  • After merging, run tests to ensure nothing is broken.

 
Step 8. Deleting a branch
 

Clean up branches you no longer need:


git branch -d feature/login-form
git push origin --delete feature/login-form
  • -d removes a local branch if it’s fully merged.
  • --delete removes the remote branch from GitHub.

 
Step 9. Visualizing branches on GitHub
 

On the GitHub website:

  • Navigate to your repository.
  • Click the “Branch” dropdown near the top-left to see all branches.
  • You can switch branches, create branches, or delete branches right from the web interface.

 
Step 10. Best practices for branches
 

  • Use descriptive branch names (e.g., feature/, bugfix/).
  • Keep branches short-lived and merge them frequently.
  • Create pull requests on GitHub to review and discuss code before merging.
  • Delete branches after they’re merged to reduce clutter.

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