Practical Git: Copy remote repos to local machines with git clone

    Trevor MillerTrevor Miller

    When working on code, we need a way to stay in sync across multiple devices and potentially multilpe team members. We also may need to work on our code offline. To do these things, we can "clone" a remote repo (from a git repo hosting service like GitHub or Bitbucket); git cloning means we make a copy of an existing remote repository onto our local machine with the git clone command. This command also automatically sets up the remote repo and branch tracking. Once our repo is cloned to our machine, we can work on the code in this directory offline or with teammates at the same time and then when we need to sync up we can push our code back to the central “remote" repo; we can also clone this same repo onto multiple machines and “pull” updates from the central “remote" repo whenever we want. In this lesson, we walk through how to do this.



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson


    00:00 We've created a directory called Cool Project, and we've moved ourselves into the directory. If we take a look inside, there's nothing here yet. What we want to do is we want to pull down a remote Git repo and place it inside of this directory.

    00:16 The remote repository that we want on our machine is located on GitHub, and right here we can see that there is this URL of where the remote is located. We're going to copy this. Now back in our Command Line, we can type Git Clone, and then paste in the URL that we copied from GitHub.

    00:37 Now if we look at what's inside this folder, we can see that we have another folder called Utility Functions, which is our cloned repo. If we move into that folder, and we output what's inside of it, we can see that it has the .git directory.

    00:51 We'd know that this is our Git repo from the remote. We also see that this folder contains a couple of files that contain our code. If we look back at our GitHub page, we can see that it's the same files that are located in the remote repository.