1 00:00:00,000 --> 00:00:05,026 [MUSIC] 2 00:00:05,026 --> 00:00:06,976 Pushing and pulling directly to and 3 00:00:06,976 --> 00:00:10,780 from your collaborators' Git repos is a good skill to have. 4 00:00:10,780 --> 00:00:15,270 But most developers today work through a Git hosting service, like GitHub, GitLab, 5 00:00:15,270 --> 00:00:16,930 or Bitbucket. 6 00:00:16,930 --> 00:00:19,920 Let's see how to apply what we've learned using a hosted repo. 7 00:00:21,100 --> 00:00:23,730 We'll be using GitHub for these demonstrations, but 8 00:00:23,730 --> 00:00:27,000 the steps are similar on other hosting platforms. 9 00:00:27,000 --> 00:00:29,190 I'm here in my original decoder repo, 10 00:00:29,190 --> 00:00:31,930 the one we were using as a remote in a previous stage. 11 00:00:32,960 --> 00:00:38,390 I've deleted the other decoder local repo, I've created a GitHub repo for 12 00:00:38,390 --> 00:00:39,490 this project. 13 00:00:39,490 --> 00:00:44,028 We'll have more info in the teachers notes if you need to review how to setup a repo 14 00:00:44,028 --> 00:00:44,712 on GitHub. 15 00:00:44,712 --> 00:00:49,586 I've followed the directions provided by GitHub to setup their repo as a remote 16 00:00:49,586 --> 00:00:51,488 on my local repo named origin. 17 00:00:53,871 --> 00:00:59,000 And this step from their setup directions probably looks familiar to you by now. 18 00:00:59,000 --> 00:01:01,110 It pushes from the local master branch, 19 00:01:01,110 --> 00:01:05,670 which I have checked out, to a remote master branch on origin. 20 00:01:05,670 --> 00:01:09,650 And because I included the -u option, it sets the origin master 21 00:01:09,650 --> 00:01:13,890 remote branch as the upstream branch for the local master branch. 22 00:01:13,890 --> 00:01:17,110 The local master branch is now a tracking branch for the remote 23 00:01:17,110 --> 00:01:21,280 origin master branch, meaning we'll be able to use git push and git pull with it. 24 00:01:22,470 --> 00:01:25,450 Now that I've pushed my master branch up to the GitHub repo, 25 00:01:25,450 --> 00:01:28,880 if I refresh my browser we'll see the master branch. 26 00:01:28,880 --> 00:01:31,568 All the files from the master branch are here, and 27 00:01:31,568 --> 00:01:34,960 the full list of commits from the master branch is here as well. 28 00:01:36,761 --> 00:01:41,147 There's a drop-down here that lets you switch between branches, but 29 00:01:41,147 --> 00:01:44,082 master is the only branch available right now. 30 00:01:44,082 --> 00:01:48,268 Let's try pushing another branch from our local repo to GitHub, 31 00:01:48,268 --> 00:01:52,922 I'll switch to the add-letters branch, git checkout add-letters. 32 00:01:54,726 --> 00:01:58,019 Add-letters has several commits that aren't on the master branch, 33 00:01:58,019 --> 00:02:01,280 including conversions up through the letter k. 34 00:02:01,280 --> 00:02:05,150 To send this branch to GitHub, we run a git push command, just like we did for 35 00:02:05,150 --> 00:02:10,210 master, git push -u origin add-letters. 36 00:02:10,210 --> 00:02:13,270 That will push our local add-letters branch to a remote 37 00:02:13,270 --> 00:02:16,990 branch named add-letters on the origin repo which is our GitHub repo. 38 00:02:18,010 --> 00:02:21,460 And because I included the -u option, our local add-letters 39 00:02:21,460 --> 00:02:26,000 branch will be set as a tracking branch for the remote origin add-letters branch. 40 00:02:26,000 --> 00:02:30,610 Allowing us to use the git pull and git push commands with the add-letters branch. 41 00:02:30,610 --> 00:02:31,960 If I refresh my browser, 42 00:02:31,960 --> 00:02:35,770 we'll see that the add letters branch is now available on GitHub. 43 00:02:35,770 --> 00:02:39,594 I can switch to the add-letters branch from the drop-down. 44 00:02:39,594 --> 00:02:44,554 The commit list now reflects the set of commits on the add letters branch, 45 00:02:44,554 --> 00:02:48,634 and the contents of the files now match the most recent commit 46 00:02:48,634 --> 00:02:50,641 on the add-letters branch. 47 00:02:52,165 --> 00:02:55,984 You'll also see a new recently pushed branches section up here at the top, 48 00:02:55,984 --> 00:02:58,360 which now includes our add-letters branch. 49 00:02:59,510 --> 00:03:01,990 There's also a pull request button, 50 00:03:01,990 --> 00:03:04,200 we'll look at what this button does in the next video.