OneBite.Dev - Coding blog in a bite size

Create a local branch from existing remote branch

If you want to test remote branch locally, you can use fetch method on git to try it on your machine

If you want to test remote branch locally, you can use fetch method on git to try it on your machine

  1. First, we need to fetch the remote branch
git fetch origin remote-branch-name

remote-branch-name is your branch name on remote Git

What is fetch in Git? Fetch is a command in Git to download commit, files and other info from a remote repository.

  1. Checkout new branch Now, we can checkout a new branch by pointing to the fetched branch above
git checkout -b local-branch origin/remote-branch-name

Your local-branch can be any name you want the branch name on your machine.

git