Difficulty: beginner
Estimated Time: 30-35 minutes

git clonegit remotegit fetchgit pushgit pull

Git's distributed collaboration model gives every developer their own copy of the repository, complete with its own local history and branch structure. Users typically need to share a series of commits rather than a single changeset. Instead of committing a changeset from a working copy to the central repository, Git lets you share entire branches between repositories.

The git remote command is one piece of the broader system which is responsible for syncing changes. Records registered through the git remote command are used in conjunction with the git fetch, git push, and git pull commands. The high level points this lab will cover are:

  • Cloning remote repository
  • Configuring remote repository
  • Fetch from and integrate with another repository
  • Update remote refs along with associated objects

By the end of this lab, you should be able to create a Git repo, use common Git commands to interact with remote repositories and share your work with others. This Scrapbook environment has been pre-configured with git installed. For more information on installing Git, please refer to the official documentation.

The most important takeaways from this lab are:

  • git clone is used to create a copy of a target repo
  • git remote is used to create, view, and delete connections to other repositories
  • git push is used to propagate changes on the local repository to remote repository
  • git fetch is used to download objects and refs from another repository
  • git pull is used to fetch from and integrate with another repository or a local branch

Don’t stop now! The next scenario will only take about 10 minutes to complete.

Git SCM - Lab 102

Step 1 of 5

Step 1 - Git Clone

Here we'll examine the git clone command in depth. git clone is a Git command line utility which is used to target an existing repository and create a clone of the target repository. If a project has already been set up in a central repository, the git clone command is the most common way for users to obtain a development copy.

Like git init, cloning is generally a one-time operation. Once a developer has obtained a working copy, all version control operations and collaborations are managed through their local repository.

The git clone clones a repository into a newly created directory, creates remote-tracking branches for each branch in the cloned repository (visible using git branch -r), and creates and checks out an initial branch that is forked from the cloned repository's currently active branch.

Repo-to-repo collaboration

It's important to understand that Git's idea of a "working copy" is very different from the working copy you get by checking out code from an SVN repository. Unlike SVN, Git makes no distinction between the working copy and the central repository—they're all full-fledged Git repositories.


This makes collaborating with Git fundamentally different than with SVN. Whereas SVN depends on the relationship between the central repository and the working copy, Git’s collaboration model is based on repository-to-repository interaction. Instead of checking a working copy into SVN’s central repository, you push or pull commits from one repository to another.



As a convenience, cloning repositories automatically creates a remote connection called origin pointing back to the original repository. This makes it very easy to interact with a central repository. This automatic connection is established by creating Git refs to the remote branch heads under refs/remotes/origin and by initializing remote.origin.url and remote.origin.fetch configuration variables. Use the command git clone <repo> to clone a repository into a newly created directory. For example;

git clone https://github.com/aossama/simple-html-app.git

will create a new directory called simple-html-app/ from the specified upstream repository.

Change to the directory of the cloned repository, use;

cd simple-html-app/


  • To clone the repository located at <repo> into the folder called <directory> using the command git clone <repo> <directory>.