How Do I Fetch All Git Branches?

Better Stack Team
Updated on June 24, 2024

To fetch all Git branches from a remote repository, you can use the git fetch command with the --all option. Here's how:

 
git fetch --all

This command fetches all branches from the remote repository, including branches that you do not have locally.

After fetching all branches, you can list them using the git branch -a command. This will show both local and remote branches, including those fetched with git fetch --all.

 
git branch -a

Note:

  • Fetching all branches from the remote repository allows you to synchronize your local repository with the latest changes from all branches on the remote.
  • Even after fetching all branches, you need to explicitly check out or create local branches based on the fetched remote branches if you want to work with them locally.
Got an article suggestion? Let us know
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github