Remote branches and GitHub3:04 with Jay McGavren
Pushing and pulling directly to and from your collaborators' Git repos is a good skill to have. But most developers today work through a Git hosting service like GitHub, GitLab, or Bitbucket. Let's see how to apply what we've learned using a hosted repo.
If you need to review how to set up a repo on GitHub, see this video from our Introduction to Git course.
[MUSIC] 0:00 Pushing and pulling directly to and 0:05 from your collaborators' Git repos is a good skill to have. 0:06 But most developers today work through a Git hosting service, like GitHub, GitLab, 0:10 or Bitbucket. 0:15 Let's see how to apply what we've learned using a hosted repo. 0:16 We'll be using GitHub for these demonstrations, but 0:21 the steps are similar on other hosting platforms. 0:23 I'm here in my original decoder repo, 0:27 the one we were using as a remote in a previous stage. 0:29 I've deleted the other decoder local repo, I've created a GitHub repo for 0:32 this project. 0:38 We'll have more info in the teachers notes if you need to review how to setup a repo 0:39 on GitHub. 0:44 I've followed the directions provided by GitHub to setup their repo as a remote 0:44 on my local repo named origin. 0:49 And this step from their setup directions probably looks familiar to you by now. 0:53 It pushes from the local master branch, 0:59 which I have checked out, to a remote master branch on origin. 1:01 And because I included the -u option, it sets the origin master 1:05 remote branch as the upstream branch for the local master branch. 1:09 The local master branch is now a tracking branch for the remote 1:13 origin master branch, meaning we'll be able to use git push and git pull with it. 1:17 Now that I've pushed my master branch up to the GitHub repo, 1:22 if I refresh my browser we'll see the master branch. 1:25 All the files from the master branch are here, and 1:28 the full list of commits from the master branch is here as well. 1:31 There's a drop-down here that lets you switch between branches, but 1:36 master is the only branch available right now. 1:41 Let's try pushing another branch from our local repo to GitHub, 1:44 I'll switch to the add-letters branch, git checkout add-letters. 1:48 Add-letters has several commits that aren't on the master branch, 1:54 including conversions up through the letter k. 1:58 To send this branch to GitHub, we run a git push command, just like we did for 2:01 master, git push -u origin add-letters. 2:05 That will push our local add-letters branch to a remote 2:10 branch named add-letters on the origin repo which is our GitHub repo. 2:13 And because I included the -u option, our local add-letters 2:18 branch will be set as a tracking branch for the remote origin add-letters branch. 2:21 Allowing us to use the git pull and git push commands with the add-letters branch. 2:26 If I refresh my browser, 2:30 we'll see that the add letters branch is now available on GitHub. 2:31 I can switch to the add-letters branch from the drop-down. 2:35 The commit list now reflects the set of commits on the add letters branch, 2:39 and the contents of the files now match the most recent commit 2:44 on the add-letters branch. 2:48 You'll also see a new recently pushed branches section up here at the top, 2:52 which now includes our add-letters branch. 2:55 There's also a pull request button, 2:59 we'll look at what this button does in the next video. 3:01
You need to sign up for Treehouse in order to download course files.Sign up