1 00:00:00,430 --> 00:00:03,715 Git is a distributed source control system. 2 00:00:03,715 --> 00:00:06,535 You could use it to just manage local projects, 3 00:00:06,535 --> 00:00:10,651 but its real power is in how it allows you to work with other 4 00:00:10,651 --> 00:00:13,876 developers by connecting to remote repositories. 5 00:00:13,876 --> 00:00:17,533 You can connect to remotes and push and pull code changes, 6 00:00:17,533 --> 00:00:20,97 all from inside Visual Studio Code. 7 00:00:20,97 --> 00:00:24,71 In the previous movie, I initialized a new local Git 8 00:00:24,71 --> 00:00:26,720 repository for my website project. 9 00:00:26,720 --> 00:00:31,423 I now want to connect it to a new empty remote repository I've 10 00:00:31,423 --> 00:00:34,198 already created on my GitHub account. 11 00:00:34,198 --> 00:00:38,691 On the source control panel, I'll click the three dots to 12 00:00:38,691 --> 00:00:40,857 open the More Actions menu. 13 00:00:40,857 --> 00:00:46,697 From there, I'll come down to the remote submenu and 14 00:00:46,697 --> 00:00:48,644 click "Add Remote." 15 00:00:48,644 --> 00:00:54,72 That opens a pop-up at the top, where I can specify a repository 16 00:00:54,72 --> 00:00:57,01 URL or choose a repository source. 17 00:00:57,01 --> 00:01:01,260 I'll choose to add a remote from GitHub. 18 00:01:01,260 --> 00:01:04,402 If you haven't authenticated VS Code to GitHub, 19 00:01:04,402 --> 00:01:06,444 you'll be prompted to log in. 20 00:01:06,444 --> 00:01:10,43 I've already done that, so after a couple of seconds, I'm 21 00:01:10,43 --> 00:01:12,792 shown a list of repositories in my account. 22 00:01:12,792 --> 00:01:17,376 The empty repository I created as the remote for this project is the 23 00:01:17,376 --> 00:01:19,223 first one here in the list. 24 00:01:19,223 --> 00:01:21,205 I'll select it, 25 00:01:21,205 --> 00:01:23,775 and I'm prompted to give it a name. 26 00:01:23,775 --> 00:01:27,480 Even though my local repository was created first, 27 00:01:27,480 --> 00:01:30,310 I'm going to follow convention and name it 28 00:01:30,310 --> 00:01:33,889 origin. 29 00:01:33,889 --> 00:01:38,554 I can now push my local main branch to the new remote. 30 00:01:38,554 --> 00:01:43,988 From the additional actions menu, I'll select "Push." 31 00:01:43,988 --> 00:01:49,503 Because the remote repository is new and doesn't yet 32 00:01:49,503 --> 00:01:51,449 have any branches, 33 00:01:51,449 --> 00:01:55,47 I get a warning letting me know that and asking if I want to 34 00:01:55,47 --> 00:01:56,510 publish the main branch. 35 00:01:56,510 --> 00:01:59,215 I'll go ahead and do that. 36 00:01:59,215 --> 00:02:01,860 After a couple of seconds, 37 00:02:01,860 --> 00:02:06,293 the publish is successful, and I now have a remote branch I can 38 00:02:06,293 --> 00:02:10,654 interact with and use to share changes with other developers. 39 00:02:10,654 --> 00:02:15,28 So far, I've shown you how to initialize a new local repository 40 00:02:15,28 --> 00:02:17,920 and push it to GitHub from inside VS code. 41 00:02:17,920 --> 00:02:22,537 However, another common workflow is to clone a remote repository 42 00:02:22,537 --> 00:02:25,102 that you don't already have locally. 43 00:02:25,102 --> 00:02:27,293 Let me quickly show you how to do that. 44 00:02:27,293 --> 00:02:33,989 I'm first going to close the folder I already have open. 45 00:02:33,989 --> 00:02:39,993 That reopens the VS Code welcome page. 46 00:02:39,993 --> 00:02:44,95 You can see that there's an option right here to clone 47 00:02:44,95 --> 00:02:45,411 a Git repository. 48 00:02:45,411 --> 00:02:48,961 In case you don't have the welcome screen configured to appear, 49 00:02:48,961 --> 00:02:52,412 I'll also show you another way to clone a repository. 50 00:02:52,412 --> 00:02:55,449 I'll first close the welcome page. 51 00:02:55,449 --> 00:02:59,462 I'll then open the source control panel. 52 00:02:59,462 --> 00:03:03,180 Because I don't currently have a project open, 53 00:03:03,180 --> 00:03:07,204 I have buttons here to either open an existing folder or 54 00:03:07,204 --> 00:03:08,594 clone a repository. 55 00:03:08,594 --> 00:03:13,224 I'll select clone repository. 56 00:03:13,224 --> 00:03:14,265 At the top, 57 00:03:14,265 --> 00:03:15,110 I'll choose that 58 00:03:15,110 --> 00:03:21,342 I want to clone a GitHub repository. 59 00:03:21,342 --> 00:03:25,915 That shows me a list of my own repositories. 60 00:03:25,915 --> 00:03:32,197 I'll search for async-csharp. 61 00:03:32,197 --> 00:03:38,197 That searches my own repositories as well as public GitHub 62 00:03:38,197 --> 00:03:39,565 repositories. 63 00:03:39,565 --> 00:03:43,784 The first result here is the repo for an earlier LinkedIn earning 64 00:03:43,784 --> 00:03:44,757 course of mine. 65 00:03:44,757 --> 00:03:48,194 If I selected it, I would then be prompted to select 66 00:03:48,194 --> 00:03:50,890 a location to store the local repository. 67 00:03:50,890 --> 00:03:53,375 I could then work on the code locally and interact 68 00:03:53,375 --> 00:03:54,187 with the remote, 69 00:03:54,187 --> 00:03:58,208 just as I would with any other Git repository. 70 00:03:58,208 --> 00:04:02,58 In addition to providing a helpful interface for the basic Git 71 00:04:02,58 --> 00:04:04,330 functionality I've already shown you, 72 00:04:04,330 --> 00:04:07,774 VS Code also lets you perform more advanced tasks 73 00:04:07,774 --> 00:04:10,386 such as resolving merge conflicts. 74 00:04:10,386 --> 00:04:13,00 I'll show you how to do that next.