---
title: "Easily Perform Git Checkout Remote Branch [Step-by-Step]"
description: "Learn how perform Git checkout remote branch, effectively track remotes, and best practices to manage remotes and branches."
canonical: "https://adamtheautomator.com/git-checkout-remote-branch/"
---

# Easily Perform Git Checkout Remote Branch [Step-by-Step]

> Learn how perform Git checkout remote branch, effectively track remotes, and best practices to manage remotes and branches.

Source: https://adamtheautomator.com/git-checkout-remote-branch/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Easily Perform Git Checkout Remote Branch \[Step-by-Step\]](https://adamtheautomator.com/wp-content/uploads/2021/03/git-checkout-remote-branch.jpg)

# Easily Perform Git Checkout Remote Branch \[Step-by-Step\]

[![](https://secure.gravatar.com/avatar/27e51fdfdee0acb33447a19c501780e43dec078b24bd8d9d9c10fd1c11a6b21c?s=192&d=mm&r=g)Devin Rich](https://adamtheautomator.com/author/devin/)20 October 20238 min. read

Categories: [Software Development](/category/software-development/)

Tags:[Git](/tag/git/)

Table of Contents

*   [Prerequisites](#h-prerequisites)
*   [Understanding a Remote Branch](#h-what-is-a-remote-branch)
*   [Mastering Git Checkout Remote Branch](#h-what-is-git-checkout-remote-branch)
*   [Clone the Remote Git Repository](#h-clone-the-remote-git-repository)
*   [What is a Git Remote and How to Track Remote Branches](#h-what-is-a-git-remote-and-how-to-track-branches)
*   [Listing a Git Repository’s Remotes](#h-listing-a-git-repositories-remotes)
*   [Viewing Available Remote Branches](#h-viewing-available-remote-branches)
*   [Updating the Available Remote Branches](#h-updating-the-available-remote-branches)
*   [Viewing Each Branch’s Remote Tracking](#h-viewing-each-branch-s-remote-tracking)
*   [Altering a Branch’s Remote Tracking](#h-changing-a-branch-s-remote-tracking)
*   [Checking out Git Remote Branches](#h-checking-out-git-remote-branches)
*   [Pushing a Local Branch to a Remote](#h-how-to-push-a-local-branch-to-a-remote)
*   [Next Steps and Additional Git Resources](#h-next-steps-and-additional-resources)

Are you a newcomer to a team and been instructed to checkout a remote branch from the Git code repository? Whether part of a sprawling enterprise or a compact team, mastering remote [Git](https://adamtheautomator.com/git-and-remove-from-commit/) branches is key to seamless code collaboration. In this guide, delve into the process of retrieving code from a remote Git repository, focusing on the ‘git checkout remote branch’ command.

Not a reader? Explore this related video tutorial!

**_Not seeing the video? Ensure your ad blocker is disabled._**

## Prerequisites

*   This tutorial employs version 2.30 of [Git SCM (source code management)](https://git-scm.com/download) on Windows 10, although it’s compatible with any Git-supported OS.

> _Other potential installation methods for Windows include [Chocolatey](https://community.chocolatey.org/packages/git) and [Git4Win](https://gitforwindows.org/)._

*   A remote Git repository from platforms like [GitLab](https://gitlab.com), [GitHub](https://github.com), or [Azure DevOps](https://azure.microsoft.com/en-us/services/devops/) is required. This article provides sample repositories for a hands-on experience, or you can utilize your own.
    *   [_https://github.com/Adam-the-Automator/git-checkout-remote-branch_](https://github.com/Adam-the-Automator/git-checkout-remote-branch)
    *   [_https://github.com/Adam-the-Automator/git-checkout-remote-branch-2_](https://github.com/Adam-the-Automator/git-checkout-remote-branch-2)

## Understanding a Remote Branch

Git repositories chronicle and track a sequence of related commits within a branch. By default, a commit resides in the currently active branch, usually termed `main` or `master`.

A remote branch is a branch located in a remote Git repository. These remote repositories, termed as “remotes,” are the destinations your local Git repository will scout for external commit updates once set up.

Discover available branches using the Git `branch` command. The branch marked with an asterisk (`*`) is the active one. The branches listed below are solely local as no remote branches have been fetched yet.

```bash
git branch
```

![git checkout remote branch - List of local branches shown from the git branch command.](https://adamtheautomator.com/wp-content/uploads/2021/03/Untitled-2021-03-24T141715.670.png)

List of local branches shown from the `git branch` command.

## Mastering Git Checkout Remote Branch

Suppose you have a local Git repository and the need arises to collaborate with other developers. This is where the [Git `checkout`](https://git-scm.com/docs/git-checkout) command comes into play, enabling you to fetch the latest commits from a remote branch on a remote Git repository.

Once a remote branch is configured, Git will mirror the remote branch instead of a local-only branch. Below is an example of the command `git checkout remote <branch>`.

```bash
git checkout remote main
```

## Clone the Remote Git Repository

Now that an existing repository is at your disposal, it’s time to dive in. Follow the steps below to clone the remote repository to a local folder on your machine.

1\. It’s often simpler to clone a remote repository [via the HTTPS URL](https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories) rather than SSH to sidestep certificate and firewall issues.

*   Head over to the repository on GitHub.
*   Hit the **Code** button and select **HTTPS**.
*   Click the **Clipboard** icon adjacent to the link to copy the URL to your clipboard.

![git checkout remote branch - Locating the HTTPS clone URL in GitHub.](https://adamtheautomator.com/wp-content/uploads/2021/03/Untitled-2021-03-24T141927.872.png)

Locating the HTTPS clone URL in GitHub.

2\. Having copied the HTTPS URL to your clipboard, open a command-line interface using your preferred CLI, such as Windows Command Prompt or the [Windows Terminal](https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-us&gl=us).

3\. Navigate to the folder where you wish the cloned repository to reside. For this tutorial, the _git_ folder in the home directory is utilized as depicted in the screenshots. Execute the following command [to clone the repository](https://git-scm.com/docs/git-clone), which creates a sub-folder housing the remote repository.

```bash
# GitHub git clone https://github.com/Adam-the-Automator/git-checkout-remote-branch
```

![git checkout remote branch - Cloning a remote repository to the local machine.](https://adamtheautomator.com/wp-content/uploads/2021/03/Untitled-2021-03-24T144215.152.png)

Cloning a remote repository to the local machine.

4\. Traverse to the cloned repository with the command, `cd git-checkout-remote-branch`.

Execute the following [status command](https://git-scm.com/docs/git-status) to ascertain that the repository has been successfully cloned. The Git `status` command unveils the differences between the local branch and remote branch, aiding in determining if your branch is connected and updated! The default Git remote is termed `origin`, prefixed to the `main` remote branch. `git status`

```bash
git status
```

![git checkout remote branch - Checking a repositories status.](https://adamtheautomator.com/wp-content/uploads/2021/03/Untitled-2021-03-24T144404.094.png)

Checking a repositories status.

> _For most modern Git software, `main` is the default primary branch. You may encounter an older application that uses `master` for their default branch name, but both names are functionally the same. This tutorial uses branches named `main`, `RemoteBranch`, `SomeBranch`, and `AnotherBranch`._

## What is a Git Remote and How to Track Remote Branches

Cloning a repository automatically creates a reference to a remote source, [known as a remote](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes). This reference is used to check for new commits or push new changes to the remote repository.

> _A Git repository itself may have multiple remotes, but a branch can only reference a single remote._

Tracking a remote branch establishes a relationship with a local branch. This relationship enables you to effortlessly push or pull commits from the remote branch to the local branch. Moreover, a tracked branch determines how far ahead or behind in commits the local branch is from the remote.

### Listing a Git Repository’s Remotes

Firstly, ensure the repository you’re working with has any Git remotes. To do this, view Git remotes in your repository with the [`git remote`](https://git-scm.com/docs/git-remote) command as shown below. In this instance, two remotes are displayed, `origin` and `remote2`.

```bash
git remote
```

![git checkout remote branch - Viewing a repositories two configured remotes.](https://adamtheautomator.com/wp-content/uploads/2021/03/Untitled-2021-03-24T144652.146.png)

Viewing a repositories two configured remotes.

> _Two additional tracked remote repositories are named `origin` and `remote2`, where your remotes may be different._

To glean more detail about the configured remotes, add the `v` switch to display the full Git remote URI.

```bash
git remote -v
```

![git checkout remote branch - Viewing verbose details about repo remotes.](https://adamtheautomator.com/wp-content/uploads/2021/03/Untitled-2021-03-24T144835.843.png)

Viewing verbose details about repo remotes.

> _You may wonder why the separate URI’s for `fetch` and `push`. Some Git workflows allow you to check for updates to a repository at a different URI than where you may send changes, this is called the [triangular workflow](https://github.blog/2015-07-29-git-2-5-including-multiple-worktrees-and-triangular-workflows/#improved-support-for-triangular-workflows)._

### Viewing Available Remote Branches

Display all available branches, both local and remote, in your repository with the `branch` command. To show the remote branches as well, append the `all` switch, as exemplified below.

```bash
git branch --all
```

In the image below, the remote repository _origin_ used in this tutorial is shown as anticipated. Nonetheless, this image omits all branches from the remote named _Remote2._

![git checkout remote branch - Viewing all known branches in a repo (including remotes).](https://adamtheautomator.com/wp-content/uploads/2021/03/Untitled-2021-03-24T145002.937.png)

Viewing all known branches in a repo (including remotes).

If a branch on your remote isn’t showing on the branch list, you must update your list of available remote branches as covered in the next section.

### Updating the Available Remote Branches

At times, a remote repository may add or alter branches. To ensure you are working with the most up-to-date branches, it’s necessary to run the [`git fetch`](https://git-scm.com/docs/git-fetch) command.

The `fetch` command connects to the remote repository, retrieving a list of all available branches. View your currently tracked branches post running the `git fetch` command to see that the remote branch is now visible, as demonstrated below.

```bash
# Retrieve available remote branches
git fetch

# Verify that all branches are now available on the local Git repository
git branch --all
```

Below, the branch `remotes/origin/RemoteBranch` is now visible in the list of available remote branches post executing the `git fetch` command.

![git checkout remote branch - Using git fetch to update the list of available remote branches.](https://adamtheautomator.com/wp-content/uploads/2021/03/Untitled-2021-03-24T145250.793.png)

Using `git fetch` to update the list of available remote branches.

The `fetch` command only checks for updates from the remote that’s currently tracked in the present branch. To have Git check for updates from all remotes in the repo, irrespective of tracking status, append the `all` parameter.

```bash
git fetch --all
```

To fetch the available branches from a specific remote, include the remote name in the `git fetch` command, like `Remote2` in the example below, which retrieves the branch, `main`.

```bash
# List available branches in a local Git repository
git branch --all
# Fetch available branches from remote2
git fetch Remote2
# Verify that the remote2 branch, main, is now available
git branch --all
```

![Fetching main from remote2 with the git fetch command.](https://adamtheautomator.com/wp-content/uploads/2021/03/Untitled-2021-03-24T145427.087.png)

Fetching `main` from `remote2` with the `git fetch` command.

> _Any time you check for remote updates with `git fetch`, [`git pull`](https://git-scm.com/docs/git-pull), or [`git push`](https://git-scm.com/docs/git-push), Git compares commits with the remote branch. Local branches can track any Git remote branch. Additionally, multiple local branches can set to track the same remote branch._

### Viewing Each Branch’s Remote Tracking

To see the tracked remote branch alongside the corresponding local branch, employ the `vv` parameter with the command `git branch`. The command results display a list of remotes and branches in the format `[<remote>/<branch>]` as illustrated below.

```bash
git branch -vv
```

![Listing remote tracking of all local branches.](https://adamtheautomator.com/wp-content/uploads/2021/03/Untitled-2021-03-24T145614.742.png)

Listing remote tracking of all local branches.

### Altering a Branch’s Remote Tracking

There might be a necessity to alter your local branch to track a different remote branch. To set your current branch to a specific remote branch, employ the `u` parameter, as illustrated below.

```bash
git branch -u Remote2/main
```

![Setting what remote to track for the current branch.](https://adamtheautomator.com/wp-content/uploads/2021/03/Untitled-2021-03-24T145731.549.png)

Setting what remote to track for the current branch.

## Checking out Git Remote Branches

With new branches created on the remote Git repository, you may need to perform a git checkout remote branch operation. Checking out a remote repository branch is executed through the [`checkout` command](https://git-scm.com/docs/git-checkout).

If the following conditions are satisfied, Git will autonomously determine the right remote, download a local copy of the remote branch, and set the local copy to track against the remote branch. Verify the following conditions are not met through the results of `git branch --all` command.

*   A local branch with the same name does not already exist.
*   Multiple remotes that use the same remote branch name do not exist.

To perform the git checkout remote branch operation, use the `git checkout` command and type the name of the remote branch as seen below.

```bash
git checkout RemoteBranch
```

![git checkout remote branch - Creating a local branch from a remote branch with git checkout.](https://adamtheautomator.com/wp-content/uploads/2021/03/Untitled-2021-03-24T145942.459.png)

Creating a local branch from a remote branch with `git checkout`.

If your local repository already contains a local branch with the same name, add the `b` parameter to specify an alternate local branch name before the remote branch to checkout.

```bash
git checkout -b AnotherBranch origin/RemoteBranch
```

![Creating a local copy of a remote branch with an alternate local branch name.](https://adamtheautomator.com/wp-content/uploads/2021/03/Untitled-2021-03-24T150215.573.png)

Creating a local copy of a remote branch with an alternate local branch name.

If your local repository has multiple remotes with the same branch name, specify which remote and branch to track local commits against.

```bash
git checkout --track origin/RemoteBranch
```

![git checkout remote branch with tracking enabled - Creating a local copy of a remote branch.](https://adamtheautomator.com/wp-content/uploads/2021/03/Untitled-2021-03-24T150253.623.png)

Creating a local copy of a remote branch with tracking enabled.

> _Future versions of Git may possibly prefer that you use the `git switch` command for changing and creating branches. The Git `switch` command is only for branches while the Git checkout command has many abilities. [Irshad S. wrote a nice primer on the rationale](https://bluecast.tech/blog/git-switch-branch/) if you’d like to read more about it._

## Pushing a Local Branch to a Remote

Upon creating a local branch devoid of a corresponding remote branch for tracking, you can propel the branch to the remote using the [`git push`](https://git-scm.com/docs/git-push) command. The most straightforward method to establish a new branch on your preferred remote is by employing the `u` parameter.

The `u` parameter, as utilized earlier, necessitates the arguments of the repository name and the source branch. By solely specifying `HEAD` as the source branch name, Git comprehends to use the current local branch name as the name on the remote, in this case, `NewBranch`.

```bash
# Checkout and switch to NewBranch
git checkout -b NewBranch
# Create NewBranch on the origin remote
git push -u origin HEAD
# Verify that the branches on the remote now exist
git branch -vv
```

![Pushing a local branch to an upstream remote named origin with the same name as local.](https://adamtheautomator.com/wp-content/uploads/2021/03/Untitled-2021-03-24T150511.111-1.png)

Pushing a local branch to an upstream remote named origin with the same name as local.

> `HEAD` is a shortcut that simply means the current branch. You can push other branches to the remote and establish tracking by using their name instead of `HEAD`.

At times, the name of the current local branch does not match with the remote branch’s name. To utilize a distinct name, specify the desired branch name after the source, joined by a colon, as demonstrated below.

```bash
# Create the current branch on the origin remote as AnotherBranch
git push -u origin HEAD:AnotherBranch
# Verify that the local NewBranch now exists as AnotherBranch on the origin remote
git branch -vv
```

![Pushing a local branch to an upstream remote named origin with an alternate remote branch name.](https://adamtheautomator.com/wp-content/uploads/2021/03/Untitled-2021-03-24T150627.602.png)

Pushing a local branch to an upstream remote named origin with an alternate remote branch name.

## Next Steps and Additional Git Resources

Having reviewed the essentials of Git, managing remotes, and performing git checkout remote branch, you are now equipped with a wealth of knowledge that will aid in averting future frustrations. The steps to checkout remote branch in Git and best practices shared will serve as invaluable resources moving forward.

Should you wish to delve deeper into other facets of managing a Git repository, the following resources are highly recommended:

*   [A primer on detached heads](https://www.cloudbees.com/blog/git-detached-head): Discover scenarios where a detached HEAD is beneficial or inadvertent, and how to handle it.
*   [Git switch](https://git-scm.com/docs/git-switch): A command dedicated to dealing with branches, unlike the multifaceted Git `checkout`.

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fgit-checkout-remote-branch%2F&text=Easily%20Perform%20Git%20Checkout%20Remote%20Branch%20%5BStep-by-Step%5D)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fgit-checkout-remote-branch%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fgit-checkout-remote-branch%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2025/04/featured-image.png)

### [Vibe Coding: How I Built a 120K Line App Without “Learning to Code”](/vibe-coding-with-ai/)

Building real applications with AI isn't just for developers anymore. Here's how I went from PowerShell scripts to a full-stack React/Express app by embracing "vibe coding" with AI.

![](https://adamtheautomator.com/wp-content/uploads/2026/08/26572_featured_image.webp)

### [PowerShell Control Flow: A Practical Guide to Conditional Logic](/powershell-control-flow-guide/)

Learn how to use PowerShell control flow including if statements, switch statements and conditional logic with practical real-world examples for server administration.

![](https://adamtheautomator.com/wp-content/uploads/2022/03/How-to-Create-a-Handy-SQL-Server-Backup-Database-Script.jpg)

### [How to Create a Handy SQL Server Backup Database Script](/sql-server-backup-database-script/)

Learn how to backup your databases regularly, whether a full or differential backup, by creating handy SQL server database backup scripts in this tutorial!

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
