1 00:00:07,480 --> 00:00:13,620 Ok so this is the last video now, on the series 'Git for Dummies'. 2 00:00:13,620 --> 00:00:21,541 So, I just want to show you how to fork a repository on github, how to commit to a forked 3 00:00:21,541 --> 00:00:24,820 repository and how to create a pull request. 4 00:00:24,820 --> 00:00:32,801 So lets consider you want to contribute to the very best and most important github repository 5 00:00:32,801 --> 00:00:33,801 on the planet. 6 00:00:33,801 --> 00:00:40,570 This is the coursera repository in the IBM organization which I’m maintaining, and 7 00:00:40,570 --> 00:00:47,160 lets assume you have found an error in one of those software components. 8 00:00:47,160 --> 00:00:52,789 I mean its impossible there is an error but just consider there is an error and you want 9 00:00:52,789 --> 00:00:53,789 to fix it. 10 00:00:53,789 --> 00:01:03,030 So what we can actually do is, you can either ask me to give you commit rights to that repository 11 00:01:03,030 --> 00:01:11,140 but its better if you just create a fork of this repository and then commit to your repository, 12 00:01:11,140 --> 00:01:13,590 to your fork and create a pull request. 13 00:01:13,590 --> 00:01:19,300 Let me show you how that works, so you see here 529 other folks already forked this repository. 14 00:01:19,300 --> 00:01:24,940 By the way just give me a star if you like, I want to have 1,000 stars soon! 15 00:01:24,940 --> 00:01:31,710 Here you can click on fork, and then it asks you where you want to fork it into. 16 00:01:31,710 --> 00:01:40,540 So this is in the IBM organization, and then I’m forking it into my private account. 17 00:01:40,540 --> 00:01:47,960 That means I will have a coursera repository in my account here, and you see here even 18 00:01:47,960 --> 00:01:55,770 its showing me 'forked from IBM/Coursera' Now I can change something, I can either make 19 00:01:55,770 --> 00:02:02,990 changes directly in here but to make it a bit more complicated, lets actually make the 20 00:02:02,990 --> 00:02:04,670 changes locally. 21 00:02:04,670 --> 00:02:22,720 So I clone it, oh I shouldn't forget to show you to add your RSA 22 00:02:22,720 --> 00:02:29,129 public key to the github repo, no, github system. 23 00:02:29,129 --> 00:02:35,260 But I will do it later, so now cloning this Coursera repository, this remote repository 24 00:02:35,260 --> 00:02:37,330 into my local repository. 25 00:02:37,330 --> 00:02:46,430 You see here again its in the 'romeokienzler' account, which is basically a copy of the 26 00:02:46,430 --> 00:02:48,299 official IBM one. 27 00:02:48,299 --> 00:02:55,090 I think we have to wait a bit because its quite huge, I should have set up two little 28 00:02:55,090 --> 00:02:59,680 test repositories but anyway, lets wait for that long. 29 00:02:59,680 --> 00:03:07,689 While we are waiting let me show you something else. 30 00:03:07,689 --> 00:03:17,530 That’s about the SSH keys, and now in our home folder, and in your home folder you have 31 00:03:17,530 --> 00:03:20,319 an SSH folder. 32 00:03:20,319 --> 00:03:24,969 I have already created the key so that’s a private key, never give it to anybody and 33 00:03:24,969 --> 00:03:29,879 never ever show it, the contents to anybody. 34 00:03:29,879 --> 00:03:37,400 And you create those and you can set a passphrase for the keys and I will put the commands for 35 00:03:37,400 --> 00:03:41,499 creating those into the description of this video. 36 00:03:41,499 --> 00:03:46,299 But that’s the public key that you can safely give to anybody and share with anybody. 37 00:03:46,299 --> 00:03:57,400 So I can also do that here, so I can show you the contents. 38 00:03:57,400 --> 00:04:05,959 So see, that’s the public key, and what I do is if I go to the github page, I have 39 00:04:05,959 --> 00:04:13,200 to go to, I think the account settings, SSH and GPG keys. 40 00:04:13,200 --> 00:04:23,380 You see here, here you have to add the key, so you can say new SSH key and you just paste 41 00:04:23,380 --> 00:04:28,000 the contents of the public key. 42 00:04:28,000 --> 00:04:31,340 And now I’m not doing that because I’ve already added it. 43 00:04:31,340 --> 00:04:33,530 But that’s all you need to do in github! 44 00:04:33,530 --> 00:04:39,780 And from now on you can use SSH because only you have the corresponding private key to 45 00:04:39,780 --> 00:04:45,130 that public key here therefore you can safely authenticate against github. 46 00:04:45,130 --> 00:04:54,340 So you also know this and I’m hoping that in the meanwhile, this other cloning is done. 47 00:04:54,340 --> 00:05:03,870 So go to coursera and lets have a look into that repository and so we have the readme 48 00:05:03,870 --> 00:05:06,150 for example, lets have a look at the readme. 49 00:05:06,150 --> 00:05:10,130 Maybe there is something I can improve on the readme. 50 00:05:10,130 --> 00:05:21,200 So this is the github project for the following 51 00:05:21,200 --> 00:05:22,200 coursera specialization. 52 00:05:22,200 --> 00:05:26,790 So lets put Coursera into a capital and save. 53 00:05:26,790 --> 00:05:36,150 Ok as you remember I need to say 'git add' and then if I say 'git status' the readme 54 00:05:36,150 --> 00:05:37,510 file is modified. 55 00:05:37,510 --> 00:05:40,700 I say ok, 'git commit'. 56 00:05:40,700 --> 00:05:45,030 I say now message and now it’s important since it’s a real repository I just can’t 57 00:05:45,030 --> 00:05:48,250 write a crap message. 58 00:05:48,250 --> 00:05:55,720 'corrected little typo' and now I say git, push OK. 59 00:05:55,720 --> 00:06:02,520 So now the corrected readme is in my local repository and in the remote repository. 60 00:06:02,520 --> 00:06:12,380 But only in my private account, if I go to this repository here, so in my private account, 61 00:06:12,380 --> 00:06:15,140 then if I click on readme. 62 00:06:15,140 --> 00:06:18,590 So first of all you see here 21 seconds ago it has been changed. 63 00:06:18,590 --> 00:06:21,320 You see here the commit message 'corrected little typo'. 64 00:06:21,320 --> 00:06:26,360 And if you click on the readme you see here now the C is now capitalcase. 65 00:06:26,360 --> 00:06:34,050 Now I want to get this change back into the official repository IBM/Coursera. 66 00:06:34,050 --> 00:06:41,460 And you see here there is a contributor, so she also committed some stuff via pull request 67 00:06:41,460 --> 00:06:46,190 into the main repository so its straightforward. 68 00:06:46,190 --> 00:06:53,180 You can create a pull request easily here, on that button and then the difference between 69 00:06:53,180 --> 00:06:58,240 my repository and the official repository is just used and you see here the only difference 70 00:06:58,240 --> 00:07:03,660 is here the little typo correction and say create pull request. 71 00:07:03,660 --> 00:07:09,490 So that’s something I’m doing as a potential contributor and I say create pull request. 72 00:07:09,490 --> 00:07:18,240 So now I myself as I’m an administrator of the IBM repository, I will get an email 73 00:07:18,240 --> 00:07:22,490 and you see here I’m already forwarded (to the IBM repository) so let’s consider I 74 00:07:22,490 --> 00:07:28,930 am not Romeo, I am somebody else the administrator of the repository and here I see there is 75 00:07:28,930 --> 00:07:37,360 a pull request coming in and I will review it So I see ok someone fixed a little typo 76 00:07:37,360 --> 00:07:41,450 in my repository that’s something that I can definitely accept. 77 00:07:41,450 --> 00:07:54,390 So I say merge pull request, confirm merge and usually what I say is merged, thanks a 78 00:07:54,390 --> 00:07:59,850 lot, or so, to be polite to your contributors. 79 00:07:59,850 --> 00:08:07,620 Now here I’m in the Coursera repository and if you now click on readme you see here, 80 00:08:07,620 --> 00:08:11,940 there’s a capitalcase and that’s basically how it looks. 81 00:08:11,940 --> 00:08:15,570 Now here you see he commit and the commit message. 82 00:08:15,570 --> 00:08:19,750 And that’s basically all, so I hope this helped you a bit and with that knowledge you 83 00:08:19,750 --> 00:08:24,750 will survive around eighty percent of your git and github problems and work. 84 00:08:24,750 --> 00:08:30,610 If you have specific questions feel free to ask me in the discussion forum or in the comments 85 00:08:30,610 --> 00:08:34,880 below the video and thanks for watching and have a nice day! 86 00:08:34,880 --> 00:08:35,880 Bye! 87 00:08:35,880 --> 00:08:36,270 Thank you very much!