1 00:00:00,360 --> 00:00:04,770 This time, we've made a change not in the medals repo but in the myclone repo, so 2 00:00:04,770 --> 00:00:08,030 let's change to that directory, cd myclone. 3 00:00:09,120 --> 00:00:12,600 Now let's take a look at what's changed, git diff. 4 00:00:12,600 --> 00:00:15,690 We realize that there was no link to the gold.html or 5 00:00:15,690 --> 00:00:20,750 the silver.html pages from the main page, so we added links and saved the file. 6 00:00:21,830 --> 00:00:27,506 Let's stage the changes, git add medals.html, 7 00:00:27,506 --> 00:00:34,120 and now let's commit them, git commit -m "Add links". 8 00:00:34,120 --> 00:00:37,960 That commit now appears in our history for the myclone repository. 9 00:00:37,960 --> 00:00:41,610 If we run git log, we'll see the add links commit at the top. 10 00:00:43,680 --> 00:00:46,780 Now as you might anticipate from seeing the previous video, 11 00:00:46,780 --> 00:00:50,340 this commit does not appear in the medals repository. 12 00:00:50,340 --> 00:00:56,130 Let's change to the parent directory, and then back down to the medals subdirectory. 13 00:00:56,130 --> 00:01:00,640 Now that we're in the medals repo, let's run git log, and 14 00:01:00,640 --> 00:01:02,750 there's no add links commit here. 15 00:01:03,850 --> 00:01:08,150 And although we were able to run git pull in the myclone repository to pull in 16 00:01:08,150 --> 00:01:12,980 commits from the medals repo, we can't pull from myclone to medals yet. 17 00:01:12,980 --> 00:01:19,185 If we run git pull myclone, we'll get the error, 18 00:01:19,185 --> 00:01:22,010 myclone does not appear to be a git repository. 19 00:01:23,480 --> 00:01:27,490 When we cloned the medals repository to the myclone repository, 20 00:01:27,490 --> 00:01:31,670 medals was automatically set up as a remote repo on myclone. 21 00:01:31,670 --> 00:01:33,966 But the reverse isn't true, in fact, 22 00:01:33,966 --> 00:01:36,967 we can try running git remote from the medals repo. 23 00:01:36,967 --> 00:01:42,464 git remote, and we don't see any remote repos at all. 24 00:01:42,464 --> 00:01:47,110 So we're going to need to add myclone as a remote on the medals repo. 25 00:01:47,110 --> 00:01:50,640 We can do this with the git remote add command. 26 00:01:51,660 --> 00:01:54,160 git remote add takes two arguments, 27 00:01:54,160 --> 00:01:57,490 the first is the name we want to give the remote repo. 28 00:01:57,490 --> 00:02:01,668 We can use any name we want, but generally it should be all lowercase. 29 00:02:01,668 --> 00:02:03,000 In the myclone repo, 30 00:02:03,000 --> 00:02:06,975 a default name of origin was used to refer to the medals repo. 31 00:02:06,975 --> 00:02:11,080 Medals wasn't cloned from myclone, though, so that's probably not appropriate here. 32 00:02:12,190 --> 00:02:16,685 Instead we'll just give it the same name as the directory we cloned it to, myclone. 33 00:02:19,700 --> 00:02:24,540 The second argument will usually be the URL of the remote repository. 34 00:02:24,540 --> 00:02:28,990 Since this remote repo is just another directory on our local computer, 35 00:02:28,990 --> 00:02:31,180 we'll give it the path to that directory instead. 36 00:02:32,200 --> 00:02:34,890 We can't just type myclone, though, 37 00:02:34,890 --> 00:02:38,950 that would indicate the myclone directory lives inside the medals directory. 38 00:02:40,140 --> 00:02:43,370 We need to indicate the myclone directory that lives alongside 39 00:02:43,370 --> 00:02:45,770 the medals directory in the parent directory. 40 00:02:45,770 --> 00:02:51,268 So we type .., for the parent directory, /myclone. 41 00:02:51,268 --> 00:02:56,025 You can read that as the parent directory's myclone subdirectory. 42 00:02:56,025 --> 00:02:57,553 Okay, so we have a name for 43 00:02:57,553 --> 00:03:02,219 the remote repo as well as the directory path that we're using in place of a URL. 44 00:03:02,219 --> 00:03:04,330 Let's hit Enter to run the command. 45 00:03:04,330 --> 00:03:08,550 We won't see any output, but as usual, that just means there were no errors. 46 00:03:09,570 --> 00:03:11,380 Now let's try running git remote again. 47 00:03:12,870 --> 00:03:17,320 This time we'll see a remote repo with the name we specified, myclone. 48 00:03:17,320 --> 00:03:21,350 So now we have a remote repo set up in the medals repo as well. 49 00:03:21,350 --> 00:03:23,570 Let's see if git pull works this time. 50 00:03:23,570 --> 00:03:29,220 git pull, we still get a no remote repository specified error. 51 00:03:29,220 --> 00:03:34,406 Let's try specifying the remote repository name, git pull myclone. 52 00:03:36,661 --> 00:03:40,553 We get an error again, but it's not myclone does not appear to be a git 53 00:03:40,553 --> 00:03:43,630 repository, so at least this is progress. 54 00:03:43,630 --> 00:03:46,660 The error says we didn't specify a branch to pull from. 55 00:03:47,760 --> 00:03:51,249 We won't be covering git branches in this introductory course. 56 00:03:51,249 --> 00:03:55,145 But you can see the teacher's notes if you'd like more info about them. 57 00:03:55,145 --> 00:03:58,960 We have to specify a branch name to get this command to work, though. 58 00:03:58,960 --> 00:04:02,320 You can get the current branch name with the git branch command. 59 00:04:04,340 --> 00:04:09,570 By default, git repositories start with only one branch, named master. 60 00:04:09,570 --> 00:04:12,100 Because we haven't created any other branches, 61 00:04:12,100 --> 00:04:16,830 our work in the myclone repo will be on the master branch there as well. 62 00:04:16,830 --> 00:04:24,487 So let's specify master as the branch name to pull from, git pull myclone master. 63 00:04:28,845 --> 00:04:31,870 That took a lot of setup, but our command finally worked. 64 00:04:31,870 --> 00:04:36,780 It pulls our new commit from the myclone remote repo into the medals repo. 65 00:04:36,780 --> 00:04:40,970 If we run git log, we'll see the Add links commit at the top. 66 00:04:42,450 --> 00:04:50,690 And if we run git log -p, it will show the actual changes to the medals.html file. 67 00:04:50,690 --> 00:04:53,460 So now you know how to add a remote repo in git. 68 00:04:53,460 --> 00:04:54,630 That's going to be important, 69 00:04:54,630 --> 00:04:58,140 because the next remote you add is going to be a GitHub repo. 70 00:04:58,140 --> 00:05:01,010 We'll show you how to share your work on GitHub in the next video.