Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Remote Git Repositories and GitHub

In this lesson, you will learn what GitHub is and how to use it with git. You’ll learn about powerful GitHub features such as:

  • Issue tracking
  • Centralized cloud hosted repositories
  • Access control and account management features
  • Advanced workflow management
  • Code review features

The lesson also covers how to use common git commands and GitHub features to setup and clone repositories, add and make changes to files and, push changes up to GitHub.

00:00 Remote Repositories and GitHub. A remote repository is a common repository to which all members of a team share their changes. So, where does GitHub come into all this?

00:13 Many teams use GitHub as that common central repository from which everyone must pull, or as a highly available repository. So, a little more about GitHub.

00:24 GitHub is based on and integrates tightly with Git, but it adds its own features and functionality on top of it. Some of the major benefits of using GitHub are an easily-accessed, centralized, cloud-hosted repository so you don’t have a single point of failure.

00:42 You get access control and account management features. You get an advanced workflow management capability with issue tracking and code review, to name a few things.

00:53 The point is, you will still use Git and the full repository is still contained in your local working directory. GitHub is just that remote repository cherry on top.

01:05 Speaking of which, you should just go ahead and create a GitHub account right now. One, so you can follow along with the rest of these examples you’re about to run through.

01:13 And two, it’s a perfect time to start getting acclimated to GitHub. You’ll probably use it a lot. GitHub is also a surprisingly awesome place for education.

01:22 There’s articles and guides all over GitHub and it’s a great place to browse and see other people’s code in the wild. Yeah! So if you’re able to now, it’s a great time to pause and make yourself a GitHub account.

01:35 It only takes a few minutes. When you come back, we’ll hop into Git and GitHub and work with local and remote repositories. Let’s quickly cover four commands you’re going to use a lot when working with remote repositories.

01:52 You will use clone to copy a repository to your local desktop. You’ll use fetch to go fetch other people’s work from the remote repository.

02:03 You’ll use pull to go fetch and then merge other people’s work into your local repository. And finally, you’ll use push to push your changes up to the remote.

02:16 And now it is time to work with GitHub, so let’s hop back into the console and go ahead and pull up GitHub in a browser. Okay. Let’s start working with GitHub a little bit here.

02:28 We’re going to create a remote repository in GitHub. So when you first log in, you’re going to have somewhere that says Repositories, and you’re going to want to find New and click it.

02:41 Make it Public or Private—it’s up to you. Go ahead and name it. We’ll stick with the Zen theme.

02:49 And generally, you always want to initialize with a README, just best practice. And something cool about GitHub is you can automatically add a .gitignore file for whichever language you’re using.

03:02 So if you go to look up Python here, it’ll automatically toss a .gitignore with common files that you’d want to ignore when working on a Python project.

03:11 Pretty handy. So, let’s go ahead and create it.

03:17 Now we have a remote repository set up on GitHub. If you come over here to the Clone or download button, you can grab what’s called the URI for the repository, and then we can tell Git to clone it to our local desktop.

03:32 So let’s try that. Go ahead and copy this URI and switch back to your terminal. And we want to make a new repository for it, so I’m going to back up one directory and just make a directory for remote_repo.

03:52 And then cd into it.

03:57 You can see right now, if I list it, that it’s empty. And now we’re going to clone our remote with git clone and then paste that URI in there.

04:13 So, what happened? Let’s check it out! We’ve got a new directory called zen_remote, which is a Git repository. And if I list it, the only thing in it right now is the README.

04:28 So, now that we have a local copy of the remote, what happens when people—say, other people working on the project—make updates to that remote repository?

04:38 They’re typically not going to come down automatically, so let’s simulate that. Let’s hop back into GitHub and just click this Create new file button here.

04:48 This will just create a text file for us.

04:56 Let’s do something like that

05:01 and then commit our new file. So now I’ve got this hello_from_remote file in our remote repo. And if we hop back into our local here, it’s not there.

05:14 This is when we do a git pull. And let’s see if it came down. Sure did! And if I list it here, let’s take a look, cat hello_from_remote.

05:28 There it is! But what happens if we make a change to that file in our local?