Course progress0%
Course content
35 min

Clone a Repository and Pull New Work

Get a first copy, then update an existing copy

By the end of this lesson

  • Choose between clone and pull
  • Update local work without confusing download and upload

Two different starting situations

Use clone when the repository does not exist on your computer:

git clone REPOSITORY_URL

Clone creates a project folder, downloads the Git history and configures the GitHub repository as origin.

Use pull when the repository already exists locally and GitHub has newer commits:

git pull

Pull retrieves remote commits and integrates them into the current local branch.

No local copy yet     -> clone once
Local copy exists     -> pull new work
Local commits to share -> push

Do not clone inside the same project

Before cloning, move to the parent folder where the new project folder should be created. Cloning the same repository inside itself produces a confusing nested project.

Pull before beginning shared work

At the start of a collaboration session:

git status
git pull

First confirm that the working folder is clean. Pulling while unrelated local work is unfinished can create avoidable confusion.

What pull does not mean

Pull does not upload your changes. It brings remote work toward your current branch. Push travels in the opposite direction.

GitHub -- pull --> your computer
GitHub <-- push -- your computer

The three situations together

  • Omar joins the project for the first time, so he uses clone.
  • Omar already has the project and Yassine merged a new commit, so he uses pull.
  • Omar created a local commit that the team needs, so he uses push.

What to remember

Clone creates the first local copy. Pull updates an existing local branch. Push publishes your commits. Always know which direction the work must travel.

Lesson complete?

Your progress is saved on this device.