Open In App

How to Show All the Branches in a GitHub Repository?

Last Updated : 31 May, 2024
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report

In this article, we'll understand the concept of branches in Git and learn how to show them using different methods. Git, a version control system, is designed to track changes in software development projects. Additionally, GitHub serves as a platform to host these projects online and facilitates collaborative coding.

Understanding Branches

Imagine you're part of a team working on a project, and you all want to add a new feature without messing up the original code. That's where branches come in handy. You can create a separate branch to work on the new feature, keeping your changes isolated from the main codebase.

Once the feature is ready, you can merge the branch back into the main code. It's like having your little playground for experimenting with code, ensuring that your changes are safe and don't disrupt the rest of the project. Branches help keep your code organized and make collaboration with others smoother without causing chaos in your codebase.

Need of Branches

  • It provides developers with a way to work on features, bug fixes, or experiments without impacting the main codebase.
  • It enables parallel development by allowing multiple developers to work on different features of the same project simultaneously.

Various Methods to Display Branches

There are two main ways to show the branches in the repository:

Graphical Interface on Github:

  • Log in to the Github platform and navigate to your repository.
  • Click on the "branches" tab on the repository page to see all available branches.
image-(1)-(1)
All branches of the repository

Git Commands

  • Open your terminal or Command propmt.
  • Navigate to your local reposiroty.

Now, you can run the following Commands on the terminal:

List all the remote branches.

git branch -r

Lists all the remote branches with the latest commit hash and commit message.

git branch -r -v

Lists all the references in the remote repository, including the branches.

git ls-remote

Shows information about the specified remote, including the remote branches.

git remote show [remoteName]

Shows all the local and remote branches.

git branch -a

Terminal Image

Screenshot-from-2024-05-25-02-48-27
Outputs of all git commands to see branches.

Article Tags :

Similar Reads