Quite often, you'll want to clone existing code to work on it. In fact, this is probably something you are going to do more often than creating a new repository. Much like developers, DevOps engineers spend more time collaborating on existing code rather than creating brand new code.
For this recipe, you need either a Red Hat- or Debian-based Linux host with a Git client installed.
Let's start cloning an existing repository:
Change your directory into the one you want to clone the existing project into.
Use the
git clone
command to clone your chosen repository:$ git clone <GIT URL>
This should give you an output similar to the following screenshot:
Once it's cloned, you can pull any changes made by other users using the
git pull
command in the working directory:$ git pull
This will connect you to the remote repository and pull any changes down to your local repository.
The git clone
command replicates the remote repository from a remote location to your local directory. This includes all branches and history; it's a complete copy of the repository. Once you've cloned it locally, you can branch, check in changes, and view history, all without the need to communicate with the remote again.
You can find more options of how to use Git clone at https://git-scm.com/docs/git-clone.