2 min read
How to get a remote branch?

Overview

So imagine, that you already cloned the repo and made some work, but somebody created another branch and you need to get this branch on your local git. How to do that?

Solution

Follow these steps:

  1. Update the branch information from the remote repository:
git fetch origin

In this command, origin is the name of the remote repository. Your remote repository might have a different name.

2. View the list of remote branches:

git branch -r

This command will display all remote branches available in the remote repository.

3. Switch to the branch you want:

git checkout <remote_branch_name>

Now you can work with this branch locally ✅.