Join James Williamson for an in-depth discussion in this video Cloning the repo locally, part of GitHub for Web Designers.
- View Offline
Other people like to go the opposite way. Which is to do everything locally. And then when they're, you know, at a good enough stage for committing, go ahead and pushing it up to a remote repo that they create. It doesn't matter which way you do it really. It's just helpful to know how both methods work and in this exercise. I'm going to show you guys, how to take a remote repository that you don't have local yet and clone it down to your local machine. So there are a couple of ways to do this. Again, I'm on the GitHub basics repository that we've been working with. If I scroll down on the right hand side of the main view of this repository, I can see that I have the HTTPS URL for cloning this repository.
So now if I wanted to I could copy that to my clipboard. I could go into terminal. And I could do a Git clone command with that URL and it would pull down the entire repo. That's certainly one way of doing that and, and the previous chapter when we were talking about terminal so much, we probably would have done it that way. But there's actually an easier way. We've already installed the client on our desktop for both Windows and Mac, depending on which platform that you're on. So if you already have it installed, this clone in desktop is a really nice option, we're going to do that one. But before we do that, I want to talk about the little button underneath it which is download ZIP.
If you do that, it's going to zip all the files in your remote repository up, and then download them to you, wherever you want them. So that's not the same as establishing a local repo, that's not what that does for you. It does allow you and anybody else that accesses this repo to download all the files, if you want to play around with them locally or work with them, but they're not going to be tied in any way to the repo. Okay, so if I click Clone in Desktop, you'll notice that Chrome is saying, whoa, wait a second, this page is trying to connect to an application, do you want to do that? I want to reassure Chrome that nothing bad's going on here, and I'm just going to tell it to launch the application.
So now what's going to happen, is the GitHub client for Mac is going to open up. Windows will do pretty much the same thing. And it's going to just, basically says okay, you're going to clone this locally. What do you want to clone it as and where do you want to put it? Well, remember earlier we created a folder out on our desktop for repos, so that's what I'm going to use. I'm going to go out to my desktop. And actually, it's a little bit easier if I do this, right? And find my repos directory. And so I'm going to say github-basics, I want to clone it as github-basics, so I don't need to change the name. I'm going to clone it to my repos. And I'll just click Clone.
It'll take it probably not more than two to three seconds, because it's really just two text files that it's going out and grabbing. But it's grabbing those and pulling them in as a local repository. So now, we have both the remote repository that created on GitHub, and we have the exact same repository cloned locally. In the location of our choosing. And it's just so super easy to do with the GitHub client. I understand using terminal, I like it, actually I'm starting to grow a lot fonder of it than I was before, but you just don't get much easier than that.
So at this point, because we have both a remote and a local repository we can certainly develop locally, and then push up to our remote repository anytime that we wanted to do that. So again, this workflow basically has someone creating a repository on GitHub. Adding some of the default settings that they want to to it. Pulling it down, cloning it locally, and then beginning to develop. Whether that work flow works for you or not, really only you are going to know. I would encourage you to experiment with a couple of different work flows of creating repositories within GitHub. Whether you start local or you start remote.
Just to find the one that's right for you. All right, we're almost done with all of our GitHub basics, but in the next exercise I'm going to show you how to get rid of repos that you don't really need anymore.
- Creating an account
- Installing GitHub
- Git basics
- Adding files to Git
- Checking differences
- Creating, switching, and updating branches
- Creating a new GitHub repository
- Managing files with the GitHub client
- Working with collaborators