Add or Clone a Remote Branch into a New Local Folder
Learn various methods to add remote branches or clone remote repositories into a local repository.
Suppose we have a new team member. The new member wants a copy of the current Git repository. We can achieve that with git clone
.
Git clone
The git clone
command can be used to clone the entire codebase of a project from any remote repository and set it up as a local repository.
One way to set up a remote repository is to create a local repository directly from a remote one. This is known as git cloning.
$ git clone <remote path> <folder name of local repository>
By default, git clone
clones the remote repository into a new directory with the same name, under the current folder.
The git clone
command expects to create that folder. So, the operation aborts when the local directory exists. It prevents the git clone
command from overriding existing files and data.
Get hands-on with 1400+ tech skills courses.