1 00:00:07,110 --> 00:00:09,120 - Okay, before I'm going to actually show you 2 00:00:09,120 --> 00:00:11,670 how to work with Git, I wanna tell you a little bit 3 00:00:11,670 --> 00:00:14,253 about Git client options to start with. 4 00:00:15,660 --> 00:00:18,090 So before you use a Git client on your computer 5 00:00:18,090 --> 00:00:20,610 it makes sense to set global options 6 00:00:20,610 --> 00:00:21,930 that's on the developer side. 7 00:00:21,930 --> 00:00:24,910 So that doesn't have to deal with what is on the website 8 00:00:25,770 --> 00:00:29,760 but it allows you to make an easier experience. 9 00:00:29,760 --> 00:00:33,420 So the global options are written to a file dot gitconfig 10 00:00:33,420 --> 00:00:36,240 and you can use the git config minus l command 11 00:00:36,240 --> 00:00:38,940 to display a list of global options. 12 00:00:38,940 --> 00:00:42,510 The list that you should do is to set your user information 13 00:00:42,510 --> 00:00:46,080 using git config minus minus global user.name 14 00:00:46,080 --> 00:00:47,070 followed by your name 15 00:00:47,070 --> 00:00:49,713 and user.email followed by your email address. 16 00:00:50,610 --> 00:00:52,920 And to set options on a project only basis. 17 00:00:52,920 --> 00:00:54,930 That's also possible you use git config 18 00:00:54,930 --> 00:00:57,093 just without the minus minus global option. 19 00:00:59,430 --> 00:01:02,613 So once you've done that, you can start working with Git. 20 00:01:03,510 --> 00:01:05,700 Working with Git starts on the Git server, 21 00:01:05,700 --> 00:01:08,550 where the upstream repository is created. 22 00:01:08,550 --> 00:01:11,700 Next, a directory on the local workstation is created 23 00:01:11,700 --> 00:01:15,150 and you use Git init to initialize the Git metadata 24 00:01:15,150 --> 00:01:16,713 in the workstation directory. 25 00:01:17,730 --> 00:01:21,240 And next, you should create a README.md, 26 00:01:21,240 --> 00:01:22,500 which is a read me file 27 00:01:22,500 --> 00:01:24,240 and this read me files for your users. 28 00:01:24,240 --> 00:01:26,670 It contains information about the contents 29 00:01:26,670 --> 00:01:28,680 of the Git directory. 30 00:01:28,680 --> 00:01:31,770 And from there, the normal Git command flow can be applied. 31 00:01:31,770 --> 00:01:35,310 So you are going to use git add to add all files 32 00:01:35,310 --> 00:01:36,720 to the staging area. 33 00:01:36,720 --> 00:01:38,940 And once you're done, you're going to use git commit 34 00:01:38,940 --> 00:01:41,490 minus M followed by the commit message 35 00:01:41,490 --> 00:01:44,220 to commit these files to the HEAD. 36 00:01:44,220 --> 00:01:47,190 Once the files are committed, you push the files 37 00:01:47,190 --> 00:01:50,373 from the HEAD to the remote repository using git push. 38 00:01:51,330 --> 00:01:53,670 Now different push methods are available 39 00:01:53,670 --> 00:01:57,360 and before issuing your first push, you can use git config 40 00:01:57,360 --> 00:02:00,510 minus minus global push.default simple 41 00:02:00,510 --> 00:02:02,610 to set the default push method. 42 00:02:02,610 --> 00:02:06,000 There are different push methods, don't worry about them. 43 00:02:06,000 --> 00:02:08,223 Simple, we'll define in most cases. 44 00:02:09,060 --> 00:02:10,590 Now let me demonstrate how to work 45 00:02:10,590 --> 00:02:12,240 with Git for your convenience. 46 00:02:12,240 --> 00:02:15,960 I've listed the steps that I'm going to do 47 00:02:15,960 --> 00:02:18,120 in this demo right here. 48 00:02:18,120 --> 00:02:19,020 In this demo, 49 00:02:19,020 --> 00:02:21,990 I'm using the Git repository name Tuesday 50 00:02:21,990 --> 00:02:24,840 use whatever kind of name you want. 51 00:02:24,840 --> 00:02:25,920 That is up to you. 52 00:02:25,920 --> 00:02:26,753 Let me show you. 53 00:02:30,750 --> 00:02:33,150 Alright, I am going to click on this icon 54 00:02:33,150 --> 00:02:34,380 in the upper left corner 55 00:02:34,380 --> 00:02:37,083 and I'm going to create a new Git repository, 56 00:02:39,690 --> 00:02:42,213 my new Git repo. 57 00:02:43,980 --> 00:02:46,050 So what do we need to specify? 58 00:02:46,050 --> 00:02:49,560 Well the default settings are good enough as they are, 59 00:02:49,560 --> 00:02:52,083 so I'm just going to click create repository. 60 00:02:53,100 --> 00:02:55,980 Now it is convenient to see right here everything 61 00:02:55,980 --> 00:02:58,860 that you should be doing, in case you don't know what to do. 62 00:02:58,860 --> 00:03:00,690 And you don't want to read my slide. 63 00:03:00,690 --> 00:03:02,880 Well, these are basically the steps that you need to do 64 00:03:02,880 --> 00:03:07,020 to initialize to git repository on the other end. 65 00:03:07,020 --> 00:03:10,710 Let's go to the other end and let me do it there. 66 00:03:10,710 --> 00:03:14,250 So here we are on the Linux site 67 00:03:14,250 --> 00:03:17,940 and I am going to start by creating directory, 68 00:03:17,940 --> 00:03:22,113 mkdir, my new git repo. 69 00:03:23,880 --> 00:03:26,250 And before I'm going to do anything with it, 70 00:03:26,250 --> 00:03:28,800 I wanna do a couple of global options. 71 00:03:28,800 --> 00:03:33,240 So git config minus minus global user.email 72 00:03:35,550 --> 00:03:38,080 and I'm going to set that to my email 73 00:03:40,380 --> 00:03:44,747 and user.name "sandervanvugt". 74 00:03:52,650 --> 00:03:55,050 Next, another common option 75 00:03:55,050 --> 00:03:57,633 is about the default branch name. 76 00:04:00,000 --> 00:04:04,650 So let's use global init.default Branch main. 77 00:04:05,490 --> 00:04:06,720 Now what is the thing? 78 00:04:06,720 --> 00:04:08,250 The thing is that the default branch 79 00:04:08,250 --> 00:04:11,280 or default environment needs to have a name. 80 00:04:11,280 --> 00:04:12,930 In the past that name was Masser. 81 00:04:12,930 --> 00:04:16,350 Nowadays Masser is considered deprecated terminology 82 00:04:16,350 --> 00:04:19,260 and you shouldn't use it anymore. 83 00:04:19,260 --> 00:04:20,340 If you agree to that 84 00:04:20,340 --> 00:04:23,460 then you should tell Git to use something else 85 00:04:23,460 --> 00:04:24,510 and that is what you can do 86 00:04:24,510 --> 00:04:28,440 using this global init.defaultBranch main. 87 00:04:28,440 --> 00:04:31,950 So from now on, if in a documentation you read Masser, 88 00:04:31,950 --> 00:04:33,630 you should replace it with main. 89 00:04:33,630 --> 00:04:36,660 Now this is really something I want to warn you about 90 00:04:36,660 --> 00:04:40,050 because a lot of documentation still has a branch 91 00:04:40,050 --> 00:04:41,520 with the name Masser. 92 00:04:41,520 --> 00:04:44,940 Well, if that doesn't correspond to your default branch 93 00:04:44,940 --> 00:04:45,840 you need to be aware 94 00:04:45,840 --> 00:04:48,240 that you need to change that branch name. 95 00:04:48,240 --> 00:04:50,190 We will probably see some examples of that 96 00:04:50,190 --> 00:04:51,840 as we move forward. 97 00:04:51,840 --> 00:04:56,460 Now let me go to this my new git repo, and let me do 98 00:04:58,320 --> 00:05:01,410 an ls minus A to show you that the directory is empty 99 00:05:01,410 --> 00:05:05,500 and now I'm going to use git init and get init is initiating 100 00:05:07,170 --> 00:05:10,170 the git administrative directory. 101 00:05:10,170 --> 00:05:11,790 It's an empty directory in which files 102 00:05:11,790 --> 00:05:16,633 will be created using echo hello greater than README.md. 103 00:05:18,810 --> 00:05:21,210 Now echo hello, that's not very much. 104 00:05:21,210 --> 00:05:23,340 If this is a real serious repository, 105 00:05:23,340 --> 00:05:25,170 you might want to consider 106 00:05:25,170 --> 00:05:28,170 putting in some actual usage information. 107 00:05:28,170 --> 00:05:31,590 For instance, this is software that people can download 108 00:05:31,590 --> 00:05:33,030 and compile and install. 109 00:05:33,030 --> 00:05:35,793 You might want to provide some instructions about that. 110 00:05:37,260 --> 00:05:39,423 Let me also create a file, 111 00:05:42,660 --> 00:05:45,690 just so that we have more than just the hello file 112 00:05:45,690 --> 00:05:48,330 and then git status. 113 00:05:48,330 --> 00:05:50,310 I like to insert a git status, 114 00:05:50,310 --> 00:05:52,740 git status is telling us no commits yet 115 00:05:52,740 --> 00:05:54,843 and there are some untracked fouls. 116 00:05:55,860 --> 00:06:00,600 Now I'm going to use git add and git status again. 117 00:06:00,600 --> 00:06:01,433 And what do we see? 118 00:06:01,433 --> 00:06:04,260 We see that we have changes to be committed. 119 00:06:04,260 --> 00:06:07,787 So when I use git commit minus M 120 00:06:10,350 --> 00:06:12,180 followed by the commit message, 121 00:06:12,180 --> 00:06:15,150 I like initial commit or something like that. 122 00:06:15,150 --> 00:06:17,340 Again, the commit message is not for you 123 00:06:17,340 --> 00:06:18,630 it's for your users. 124 00:06:18,630 --> 00:06:20,760 So be as specific as you can. 125 00:06:20,760 --> 00:06:23,190 And here we can see that the files are committed 126 00:06:23,190 --> 00:06:27,210 and when I use git status, we can see that we are on 127 00:06:27,210 --> 00:06:29,760 the branch main and the tree is clean. 128 00:06:29,760 --> 00:06:31,623 So they are ready for takeoff. 129 00:06:32,610 --> 00:06:33,443 What's next? 130 00:06:33,443 --> 00:06:35,370 Well, let me first pop the slide so that you can see 131 00:06:35,370 --> 00:06:37,270 the next couple of steps on the slide. 132 00:06:40,290 --> 00:06:43,500 So here we have the next couple of steps in the procedure. 133 00:06:43,500 --> 00:06:44,343 Let me show you. 134 00:06:49,530 --> 00:06:54,530 So now I need to to specify get Branch minus M main. 135 00:06:55,740 --> 00:06:57,273 Well, I need to specify we've set it 136 00:06:57,273 --> 00:07:00,390 as a default so I don't even have to specify it 137 00:07:00,390 --> 00:07:02,310 but I want you to be aware of this option. 138 00:07:02,310 --> 00:07:04,560 It's a common option that you are going to need 139 00:07:04,560 --> 00:07:05,583 sooner or later. 140 00:07:06,450 --> 00:07:10,470 And now next, git remote add origin 141 00:07:10,470 --> 00:07:15,470 https://github.com/your username/name of the repo 142 00:07:19,320 --> 00:07:22,623 My new git repo. 143 00:07:24,090 --> 00:07:26,220 And now we are about ready to push. 144 00:07:26,220 --> 00:07:27,720 But before I'm going to push, 145 00:07:27,720 --> 00:07:29,613 I need my personal access token. 146 00:07:34,860 --> 00:07:37,410 And this is the reason why I'm storing it in a file 147 00:07:44,220 --> 00:07:48,660 and I'm copying it so that it is ready because git push 148 00:07:48,660 --> 00:07:53,280 minus U origin main is what I'm going to use to push. 149 00:07:53,280 --> 00:07:58,280 And there it has the the username. 150 00:07:58,710 --> 00:08:03,420 So the username still might get username and the password, 151 00:08:03,420 --> 00:08:05,160 well, that is not the password 152 00:08:05,160 --> 00:08:07,650 that I'm using to log into the console. 153 00:08:07,650 --> 00:08:09,810 That is the git access token. 154 00:08:09,810 --> 00:08:10,710 So there we go. 155 00:08:10,710 --> 00:08:12,780 Git access token is now used 156 00:08:12,780 --> 00:08:16,650 and we can see that the files are synchronized. 157 00:08:16,650 --> 00:08:18,750 Now to wrap it up, we should have a look 158 00:08:18,750 --> 00:08:21,663 at the Git repository on the GitHub website. 159 00:08:22,530 --> 00:08:24,550 So here we have my new git repo 160 00:08:25,500 --> 00:08:28,680 and look at that, README.md and new file. 161 00:08:28,680 --> 00:08:33,363 So mission accomplished and we are good to continue.