1 00:00:00,000 --> 00:00:11,520 So now that you have set up your repository, we can talk about working with repositories. 2 00:00:11,520 --> 00:00:18,760 But first, let me repeat what we have just done in the strong authentication setup. 3 00:00:18,760 --> 00:00:23,959 The issue is that GitHub does not accept username and password authentication anymore. 4 00:00:23,959 --> 00:00:28,040 And as an easy alternative, you can use SSH key base authentication. 5 00:00:28,040 --> 00:00:32,560 I would recommend you do that because it's a native protocol to Linux and should be easy 6 00:00:32,560 --> 00:00:34,160 to set up. 7 00:00:34,160 --> 00:00:40,880 So first, on Linux, you need to create a key pair using ssh-keygen-t ed25519, that's a 8 00:00:40,880 --> 00:00:46,720 key type, and "-c", followed by your email address, because your email address is used 9 00:00:46,720 --> 00:00:49,799 to identify yourself on GitHub. 10 00:00:49,799 --> 00:00:56,840 Then you add your key to the SSH agent on your local machine using eval ssh-agent-s 11 00:00:56,840 --> 00:01:02,279 ssh-add, followed by the private key that you have just used. 12 00:01:02,279 --> 00:01:07,320 By doing so, you make sure that it is cached, and that is particularly convenient if you 13 00:01:07,320 --> 00:01:10,519 have any passphrases securing your private key. 14 00:01:10,519 --> 00:01:12,919 Then you need to get the content of the public key. 15 00:01:12,919 --> 00:01:20,279 You can do that by getting it from the .ssh-id-underscore-ed25519.pub file. 16 00:01:20,279 --> 00:01:24,639 Now you need to go to the GitHub website, where on your GitHub account, Settings, SSH 17 00:01:24,639 --> 00:01:32,480 and GPG keys, you add the new SSH key, and make sure to save it, and set the remote on 18 00:01:32,480 --> 00:01:36,279 your Linux machine based on the SSH URL. 19 00:01:36,279 --> 00:01:40,680 So the git remote that you have seen on the previous slides needs to be changed, and this 20 00:01:40,680 --> 00:01:42,160 is how you change it. 21 00:01:42,160 --> 00:01:46,120 So git remote set-url origin git add github.com. 22 00:01:46,120 --> 00:01:48,720 That specifies the Git protocol. 23 00:01:48,720 --> 00:01:53,879 There you use your username, followed by the name of the repo, .git. 24 00:01:53,879 --> 00:01:55,919 And then it should be all set. 25 00:01:55,919 --> 00:01:59,199 And now you can start using your Git repositories. 26 00:01:59,199 --> 00:02:04,879 So the basic skills, you can use git clone HTTPS git server slash repo name to clone 27 00:02:04,879 --> 00:02:09,199 the contents of a remote repository to your server. 28 00:02:09,199 --> 00:02:13,779 And to update the local repository to the latest commit, use git pull. 29 00:02:13,779 --> 00:02:18,880 So if in between somebody has changed the content of the remote Git repository, git 30 00:02:18,880 --> 00:02:22,520 pull will synchronize your local system. 31 00:02:22,520 --> 00:02:27,720 So if you are a developer, every now and then you probably want to upload changed files. 32 00:02:27,720 --> 00:02:32,039 And modified files need to go through the staging process. 33 00:02:32,039 --> 00:02:36,759 So after changing files, you use git status to see which files have changed. 34 00:02:36,759 --> 00:02:40,880 Then you use git add to add these files to the staging area. 35 00:02:40,880 --> 00:02:44,759 Alternatively, sometimes you also need to remove files. 36 00:02:44,759 --> 00:02:47,039 Git rm will remove the file. 37 00:02:47,039 --> 00:02:51,440 It will remove the file from your current repository. 38 00:02:51,440 --> 00:02:56,839 And it will also flag it for removal in the remote. 39 00:02:56,839 --> 00:03:01,320 And then you can use git commit minus m with a commit message. 40 00:03:01,320 --> 00:03:03,119 Use any message that you want. 41 00:03:03,119 --> 00:03:07,720 And finally, you can use git push origin main to push your changes. 42 00:03:07,720 --> 00:03:12,320 And next, from any client, git pull can be used to update the current Git clone. 43 00:03:12,320 --> 00:03:13,919 Let me show you. 44 00:03:13,919 --> 00:03:16,839 So I'm going to copy some new files. 45 00:03:16,839 --> 00:03:21,240 I'm going to paste the ATC G star to here. 46 00:03:21,240 --> 00:03:23,839 And LS is showing the new files. 47 00:03:23,839 --> 00:03:27,440 So in the Git repo, I'm using git status. 48 00:03:27,440 --> 00:03:32,240 And git status is giving me information about untracked files. 49 00:03:32,240 --> 00:03:37,039 So that is what I'm going to fix using git add G star. 50 00:03:37,039 --> 00:03:38,440 Or just git add star. 51 00:03:38,440 --> 00:03:40,440 That will be okay as well. 52 00:03:40,440 --> 00:03:45,839 Now, git status once more is showing that we have changes to be committed. 53 00:03:46,440 --> 00:03:48,039 They are in the staging area. 54 00:03:48,039 --> 00:03:49,839 Git now knows about them. 55 00:03:49,839 --> 00:03:57,839 And I can use git commit minus m followed by the message that you want to use. 56 00:03:57,839 --> 00:03:58,639 Minor changes. 57 00:03:58,639 --> 00:03:59,839 Good enough. 58 00:03:59,839 --> 00:04:04,240 Next, I'm using git push origin main. 59 00:04:04,240 --> 00:04:07,440 And it will push the changes to the Git repository. 60 00:04:07,440 --> 00:04:08,520 And now we're all done. 61 00:04:08,520 --> 00:04:13,240 So any client who is using git pull will get access to the updated files.