How to checkout a remote branch in Git
In this tutorial, we are going to learn about how to fetch and checkout a remote branch in git.
Git checkout remote branch
- Run the
git fetch origincommand to get all remote branches of a repository in your local machine.
git fetch origin- Now, checkout the remote branch by using the
git checkoutcommand followed by your branch name.
git checkout demo2Similar solution
If the above solution doesn’t work follow the below solution.
- Run the following command in your terminal.
git fetch origin 'your_remote_branch':'local_branch_name'This above command will fetch a remote branch and create a new local branch with the local_branch_name and track the remote branch inside that local branch.
- Now, checkout to your remote branch.
git checkout local_branch_name

