In this article, we will see how to use
git checkout to create a local copy of a remote branch.
In order to create a local copy of remote branch, First, we need to fetch the remote branch. Open the terminal & navigate to the git repository and enter the following command.
git fetch origin remote-branch-name
The above command, fetches the remote branch and create a copy in the local repository.
Now, using the
git checkout we will switch to the local copy of the remote branch. Use the following command.
git checkout -b local-branch-name origin/remote-branch-name
local-branch-name with the name of your new local branch.
After running the above command you will be switched to a local branch & -b option tells the git to create a new local branch with the remote branch changes.