This lesson is for PRO members.

Unlock this lesson NOW!
Already subscribed? sign in

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

1:06 Tools lesson by

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.

Get the Code Now
click to level up

egghead.io comment guidelines

Avatar
egghead.io

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.

Avatar
Oleg

Thanks for great lessons!
How to upgrade the terminal to show not folder only, but also the branch name [master]?

In reply to egghead.io
Avatar
Trevor

Thanks Oleg! You can customize your terminal prompt depending on which shell you use. If you google "how to add git branch to {your shell} prompt" that should give you some results. For me, I use bash and the GitHub git bash scripts, so here is an example: https://coderwall.com/p/fasnya/add-git-branch-name-to-bash-prompt

In reply to Oleg
Avatar
Oleg

Thanks Trevor! It was helpful for me.

In reply to Trevor

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.

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.

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.

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.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?