The simplest method for fetching a remote branch in Git.

Assume you're a team member and a developer sends you a Pull Request to merge.

The developer creates their own branches to ensure proper code tracking and code quality.

These branches will generate Pull Requests, which must be merged into the main branch.

You don't want to merge code if you're not sure if it works. To test the code, run it in an environment that is not accessible to your product's users.

Apart from being a Control Version System, git has some amazing features, one of which is the Fetch. That is precisely the purpose of this resource. I'll show you the simplest methods for fetching branches from remote git.

Let's dive in.

The git switch command is a new command to Git. The command, as the name implies, will switch to a specified local branch. Continue reading to find out more.


git switch [branch_name]


Assuming the local branch is bar, you would

git switch bar

Something to note about the git switch is that it will fetch updates of the remote branch and save you a lot of typing time.

However, if the branch does not exist in the local repository, make use of two commands.

git fetch
git switch bar

An alternative and largely trusted method of fetching a specific branch from the remote repo is.

  1. git fetch [remote_repo_name] [remote_branch]:[local_branch]
  2. git checkout [local_branch]



  • Remote repository alias is origin
  • Remote branch name is foo
  • Local branch name is bar

The procedure will be like the one below.

git fetch origin foo:bar
git checkout bar

Let me know what you think about this tip. Share your thoughts in the comment section below.