1 00:00:00,280 --> 00:00:02,610 When commits get added to a git repository, 2 00:00:02,610 --> 00:00:06,270 they aren't automatically copies or clones of that repository. 3 00:00:06,270 --> 00:00:10,940 One way to distribute the new commits is to pull them in from other repos. 4 00:00:10,940 --> 00:00:12,900 In our original medals repo, 5 00:00:12,900 --> 00:00:17,760 we've saved a gold.html file, that advertises our gold medals. 6 00:00:17,760 --> 00:00:22,192 We're in the myclone repo right now, but we need to be in the medals repo. 7 00:00:22,192 --> 00:00:25,400 So let's change into it with the cd command. 8 00:00:25,400 --> 00:00:27,712 We can't just type cd medals, though, 9 00:00:27,712 --> 00:00:32,270 that would indicate the medals directory lives inside the myclone directory. 10 00:00:33,700 --> 00:00:37,837 The medals directory actually exists alongside the myclone directory in 11 00:00:37,837 --> 00:00:39,610 the parent directory. 12 00:00:39,610 --> 00:00:44,110 Remember how we've been typing cd .. to change to the parent directory? 13 00:00:44,110 --> 00:00:48,990 We can use that here, but now we need to indicate that we mean the medals directory 14 00:00:48,990 --> 00:00:50,960 inside the parent directory. 15 00:00:50,960 --> 00:00:55,320 Directory names on UNIX-like systems are joined with a slash character. 16 00:00:55,320 --> 00:00:59,917 So we'll add a slash, then we'll type the name of the directory, medals. 17 00:00:59,917 --> 00:01:02,533 That leaves us with ../medals, 18 00:01:02,533 --> 00:01:07,880 you can read that as the parent directory's medals subdirectory. 19 00:01:07,880 --> 00:01:11,100 If we run the command, it will change up to the parent directory and 20 00:01:11,100 --> 00:01:13,720 then into the medals subdirectory. 21 00:01:13,720 --> 00:01:17,520 You don't have to remember this double dot notation for directory names, but 22 00:01:17,520 --> 00:01:19,390 we will be using it later in the stage. 23 00:01:19,390 --> 00:01:21,250 So at least now you'll know what's going on. 24 00:01:22,320 --> 00:01:27,010 Now we're in the medals repo, where our new gold.html file is saved. 25 00:01:27,010 --> 00:01:31,484 Let's stage it with git add gold.html, and 26 00:01:31,484 --> 00:01:37,385 now we'll commit it, git commit -m "Add gold medals". 27 00:01:40,430 --> 00:01:44,467 Now let's run git log, we'll see the new commit in the history for 28 00:01:44,467 --> 00:01:47,420 the medals repo, Add gold medals. 29 00:01:47,420 --> 00:01:49,930 I'll press q to quit out of the history. 30 00:01:49,930 --> 00:01:53,340 But will that commit also be in the history for the my clone repo? 31 00:01:53,340 --> 00:01:58,320 Let's find out, I'll type cd ../myclone/. 32 00:01:58,320 --> 00:02:02,130 Again, the slash here at the end of the myclone directory name is optional. 33 00:02:03,340 --> 00:02:06,770 Let's run git log again here in the myclone repo. 34 00:02:06,770 --> 00:02:09,670 There's no sign of the Add gold medals commit. 35 00:02:09,670 --> 00:02:15,280 And if I quit out of the log and run ls, there's no gold.html file. 36 00:02:15,280 --> 00:02:19,810 We need to get the commit that adds gold.html from the medals repo to 37 00:02:19,810 --> 00:02:21,610 the myclone repo. 38 00:02:21,610 --> 00:02:26,380 To do that, we need a link from the myclone repo back to the medals repo. 39 00:02:26,380 --> 00:02:30,130 Within a git repository, you can add links to other repos. 40 00:02:30,130 --> 00:02:34,030 These linked repos are referred to as remote repos. 41 00:02:34,030 --> 00:02:37,780 We can get a list of remote repos with the git remote command. 42 00:02:39,320 --> 00:02:43,440 We see one remote repo listed here named origin. 43 00:02:43,440 --> 00:02:44,940 When you clone a git repo, 44 00:02:44,940 --> 00:02:49,210 the original repo is automatically added as a remote on the clone. 45 00:02:49,210 --> 00:02:51,510 You can name remote repos whatever you want. 46 00:02:51,510 --> 00:02:54,400 But the default used when cloning is origin, 47 00:02:54,400 --> 00:02:58,330 because it represents the repo this clone originated from. 48 00:02:58,330 --> 00:02:59,570 Because of this default, 49 00:02:59,570 --> 00:03:04,090 you'll see a remote repo named origin on most git repos you work with. 50 00:03:04,090 --> 00:03:08,630 In fact, in many cases, the origin repo will be the only remote repo. 51 00:03:08,630 --> 00:03:13,080 Because everyone on the project just pulls changes from that single repo. 52 00:03:13,080 --> 00:03:17,380 Since a remote repo is already set up, we're ready to pull changes from it. 53 00:03:17,380 --> 00:03:20,680 We do this with the git pull subcommand. 54 00:03:20,680 --> 00:03:23,390 git pull takes an argument with the name of the remote 55 00:03:23,390 --> 00:03:28,000 repo you want to pull changes from, so we'll pull from origin. 56 00:03:28,000 --> 00:03:32,540 But just as the repo we cloned from was set up as a remote repo automatically, 57 00:03:32,540 --> 00:03:35,620 it was also set up as the default repo to pull from. 58 00:03:35,620 --> 00:03:38,020 So we can actually omit the remote repo name. 59 00:03:40,740 --> 00:03:45,060 And just run git pull, when we run it, we'll see some info about the commits 60 00:03:45,060 --> 00:03:49,430 being pulled over, and any files that are being added or updated. 61 00:03:49,430 --> 00:03:53,460 We can see the gold.html file here in the output. 62 00:03:53,460 --> 00:03:56,980 Now we can run git log within the myclone repo. 63 00:03:56,980 --> 00:03:58,080 And here in the output, 64 00:03:58,080 --> 00:04:02,390 we'll see the Add gold medals commit, just like we did in the medals repo. 65 00:04:04,090 --> 00:04:07,870 And if we run ls, we'll see the gold.html file. 66 00:04:07,870 --> 00:04:11,980 So now you know what a remote repository is and how to pull commits from one. 67 00:04:11,980 --> 00:04:15,720 But this remote repo was added automatically for us by git. 68 00:04:15,720 --> 00:04:19,870 What happens if you need to add a remote yourself, we'll see how to do that next.