All language subtitles for 5. Git Fundamentals

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian Download
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 1 00:00:01,320 --> 00:00:05,390 Let's now quickly go over the basics of Git. 2 2 00:00:05,390 --> 00:00:07,930 And this video is by no means 3 3 00:00:07,930 --> 00:00:10,820 gonna be a complete overview of Git. 4 4 00:00:10,820 --> 00:00:13,410 All I want to do here is to get you started 5 5 00:00:13,410 --> 00:00:15,580 as quick as possible with Git, 6 6 00:00:15,580 --> 00:00:18,867 so that we can then push our project to GitHub. 7 7 00:00:20,710 --> 00:00:25,390 All right, now before we can do anything else with git, 8 8 00:00:25,390 --> 00:00:26,590 in each repository, 9 9 00:00:26,590 --> 00:00:30,193 we should have a git ignore file like this. 10 10 00:00:31,160 --> 00:00:34,810 So if VS code didn't create it automatically for you, 11 11 00:00:34,810 --> 00:00:37,070 as it did for me in the last lecture, 12 12 00:00:37,070 --> 00:00:39,983 then please go ahead and create this file right now. 13 13 00:00:40,890 --> 00:00:42,760 So it starts with a dot, 14 14 00:00:42,760 --> 00:00:44,570 and then Git ignore. 15 15 00:00:44,570 --> 00:00:46,930 And inside of this file, 16 16 00:00:46,930 --> 00:00:50,400 we can put all the folders and also files, 17 17 00:00:50,400 --> 00:00:53,150 which we want Git to ignore, 18 18 00:00:53,150 --> 00:00:55,903 or in other words, folders and files 19 19 00:00:55,903 --> 00:00:59,660 that we do not want to get into our repository. 20 20 00:00:59,660 --> 00:01:03,370 And node modules is a perfect example of that. 21 21 00:01:03,370 --> 00:01:05,750 Because, well, we can always get 22 22 00:01:05,750 --> 00:01:08,890 this code back from NPM, right? 23 23 00:01:08,890 --> 00:01:12,230 It is not part of our original source code. 24 24 00:01:12,230 --> 00:01:16,870 And so therefore, we don't need it in our Git repository. 25 25 00:01:16,870 --> 00:01:21,390 And actually, the same is true for our dist folder. 26 26 00:01:21,390 --> 00:01:23,880 Right, so the dist folder, 27 27 00:01:23,880 --> 00:01:26,130 essentially only contains code 28 28 00:01:26,130 --> 00:01:29,350 that was built from our source code. 29 29 00:01:29,350 --> 00:01:32,630 And so again, this is actually code 30 30 00:01:32,630 --> 00:01:35,770 that we do not need in our Git repository. 31 31 00:01:35,770 --> 00:01:37,860 So usually, in the repository, 32 32 00:01:37,860 --> 00:01:41,220 we only want like the original source code, 33 33 00:01:41,220 --> 00:01:43,290 and everything that is necessary 34 34 00:01:43,290 --> 00:01:48,280 in order to basically compile our final project later. 35 35 00:01:48,280 --> 00:01:51,643 So let's actually also exclude the dist folder here. 36 36 00:01:53,700 --> 00:01:55,600 Now, this is not mandatory, 37 37 00:01:55,600 --> 00:01:59,470 and some people want also to keep their dist folder 38 38 00:01:59,470 --> 00:02:01,340 in the Git repository. 39 39 00:02:01,340 --> 00:02:05,310 But personally, I think it's a good idea not to include it. 40 40 00:02:05,310 --> 00:02:09,460 And so you see that now, it got grayed out here as well. 41 41 00:02:09,460 --> 00:02:12,333 And the same for the parcel cache folder. 42 42 00:02:13,170 --> 00:02:14,853 So that we also don't want. 43 43 00:02:16,070 --> 00:02:20,163 So .parcel-cache. 44 44 00:02:21,090 --> 00:02:22,780 So that's gone now. 45 45 00:02:22,780 --> 00:02:25,030 And now here, VS code shows us 46 46 00:02:25,030 --> 00:02:27,560 that there are basically 28 files 47 47 00:02:27,560 --> 00:02:30,613 in our repository that are pending changes. 48 48 00:02:31,600 --> 00:02:35,310 So this here is enough for our Git ignore. 49 49 00:02:35,310 --> 00:02:37,080 Now only if you're using the Mac, 50 50 00:02:37,080 --> 00:02:41,663 you can add one type of file here, which is the .Ds_Store, 51 51 00:02:46,010 --> 00:02:47,930 which is some kind of weird file 52 52 00:02:47,930 --> 00:02:50,963 that Mac OS sometimes adds to our directories. 53 53 00:02:52,610 --> 00:02:53,443 But with this here, 54 54 00:02:53,443 --> 00:02:57,123 I think we're already at a good starting point, okay? 55 55 00:02:58,580 --> 00:03:02,697 So let's now run a Git command called git status. 56 56 00:03:05,030 --> 00:03:06,820 And so this shows us here, 57 57 00:03:06,820 --> 00:03:10,570 that all of these files are untracked files. 58 58 00:03:10,570 --> 00:03:13,610 And we can also see that we are on branch Master, 59 59 00:03:13,610 --> 00:03:16,190 and that there are no commits yet. 60 60 00:03:16,190 --> 00:03:19,060 So all of these files here are untracked. 61 61 00:03:19,060 --> 00:03:21,080 And so now we need to track them, 62 62 00:03:21,080 --> 00:03:24,240 which in terms of git means to add them 63 63 00:03:24,240 --> 00:03:26,890 to the so called Staging area. 64 64 00:03:26,890 --> 00:03:29,560 So you can also see here in VS code, 65 65 00:03:29,560 --> 00:03:32,080 that these files are now untracked. 66 66 00:03:32,080 --> 00:03:34,023 So that's what this U stands for. 67 67 00:03:35,230 --> 00:03:38,350 Okay, but now, let's add all these files 68 68 00:03:38,350 --> 00:03:43,090 to the staging area by saying git add, 69 69 00:03:43,090 --> 00:03:47,880 and then dash A, which stands for all the files. 70 70 00:03:47,880 --> 00:03:50,260 Now, we could also add files manually. 71 71 00:03:50,260 --> 00:03:54,400 So one by one, but usually that's never necessary. 72 72 00:03:54,400 --> 00:03:57,690 So I will simply add all of my files now. 73 73 00:03:57,690 --> 00:04:01,623 And so these files are now basically part of the repository. 74 74 00:04:02,500 --> 00:04:05,880 Okay, and so now here it says, edit. 75 75 00:04:05,880 --> 00:04:08,850 And so these files are now basically tracked, 76 76 00:04:08,850 --> 00:04:09,973 they are active. 77 77 00:04:11,350 --> 00:04:15,600 Okay, then let's say we do some change in one of them, 78 78 00:04:15,600 --> 00:04:17,113 let's say in the controller, 79 79 00:04:18,270 --> 00:04:20,450 let's just log something to the console 80 80 00:04:20,450 --> 00:04:24,643 in the init function, let's say welcome. 81 81 00:04:25,700 --> 00:04:30,260 And so now you see that this file was modified, right? 82 82 00:04:30,260 --> 00:04:33,550 And also immediately here on the sidebar, 83 83 00:04:33,550 --> 00:04:36,620 VS code tells us that something has changed. 84 84 00:04:36,620 --> 00:04:39,420 And so green here means that something was added. 85 85 00:04:39,420 --> 00:04:42,800 And when we click that, we can actually see the change. 86 86 00:04:42,800 --> 00:04:45,483 So the plus here means that something was added. 87 87 00:04:47,620 --> 00:04:49,903 And if we see git status now again, 88 88 00:04:51,880 --> 00:04:54,860 you will see that all of these files here, 89 89 00:04:54,860 --> 00:04:56,890 are ready to be committed. 90 90 00:04:56,890 --> 00:04:58,940 So they are being tracked, 91 91 00:04:58,940 --> 00:05:02,090 and then there's this modified file. 92 92 00:05:02,090 --> 00:05:04,550 And so in order to now commit all these files 93 93 00:05:04,550 --> 00:05:09,550 to our Git repository, I need to run git add all again. 94 94 00:05:11,790 --> 00:05:15,743 So now you see that it is back to just being added. 95 95 00:05:16,740 --> 00:05:19,370 And also this green bar here is gone. 96 96 00:05:19,370 --> 00:05:21,180 All right, and so now we're ready 97 97 00:05:21,180 --> 00:05:24,070 to finally commit these files. 98 98 00:05:24,070 --> 00:05:26,460 And committing the files basically means 99 99 00:05:26,460 --> 00:05:28,920 that we really save the modifications 100 100 00:05:28,920 --> 00:05:32,320 of all the files to the repository. 101 101 00:05:32,320 --> 00:05:34,530 So adding the files, like this here, 102 102 00:05:34,530 --> 00:05:38,530 is basically just a pre step before the commit. 103 103 00:05:38,530 --> 00:05:41,370 So a commit is gonna be like a snapshot 104 104 00:05:41,370 --> 00:05:44,690 of your code at a certain point in time. 105 105 00:05:44,690 --> 00:05:46,670 So each time before you make some 106 106 00:05:46,670 --> 00:05:49,090 significant changes to your codebase, 107 107 00:05:49,090 --> 00:05:50,720 you should always commit. 108 108 00:05:50,720 --> 00:05:52,720 And so then, if necessary, 109 109 00:05:52,720 --> 00:05:55,100 you can go back to past commits, 110 110 00:05:55,100 --> 00:05:57,830 and delete any modifications that you did 111 111 00:05:57,830 --> 00:05:59,610 that were maybe wrong. 112 112 00:05:59,610 --> 00:06:01,860 And we will see how to do that actually later 113 113 00:06:01,860 --> 00:06:03,410 in this lecture. 114 114 00:06:03,410 --> 00:06:07,240 But for now, let's commit what we already have here. 115 115 00:06:07,240 --> 00:06:12,240 So git commit, then dash M, which stands for message. 116 116 00:06:13,710 --> 00:06:16,120 And then here, we need to specify a string, 117 117 00:06:16,120 --> 00:06:18,400 which is the commit message. 118 118 00:06:18,400 --> 00:06:21,060 And so usually, the first commit is always 119 119 00:06:21,060 --> 00:06:25,910 gonna be called initial commit, like this. 120 120 00:06:25,910 --> 00:06:28,350 Now, okay, and that's it. 121 121 00:06:28,350 --> 00:06:30,090 Now, they're all committed. 122 122 00:06:30,090 --> 00:06:33,240 And you see that all the files, 123 123 00:06:33,240 --> 00:06:35,053 now look normal here again. 124 124 00:06:35,920 --> 00:06:39,533 All right, and if we now take a look again, at git status, 125 125 00:06:41,200 --> 00:06:44,050 then you will see that there is nothing to commit, 126 126 00:06:44,050 --> 00:06:45,843 and the working tree is clean. 127 127 00:06:46,850 --> 00:06:48,970 Alright, so in summary, 128 128 00:06:48,970 --> 00:06:52,500 whenever we initialize a new Git repository, 129 129 00:06:52,500 --> 00:06:56,220 usually I immediately add all the files, 130 130 00:06:56,220 --> 00:06:59,700 so I do git in it, then after that, 131 131 00:06:59,700 --> 00:07:02,490 immediately I run this command. 132 132 00:07:02,490 --> 00:07:04,750 So Git at all the files. 133 133 00:07:04,750 --> 00:07:06,670 And then immediately after that, 134 134 00:07:06,670 --> 00:07:10,563 I commit everything as the initial commit, all right? 135 135 00:07:12,700 --> 00:07:15,810 Now, let's say that we do some modifications here, 136 136 00:07:15,810 --> 00:07:17,660 in multiple files. 137 137 00:07:17,660 --> 00:07:20,143 But we actually introduce some kind of a bug, 138 138 00:07:21,090 --> 00:07:22,920 not writing any real code, 139 139 00:07:22,920 --> 00:07:25,543 I will just put a bug here now. 140 140 00:07:26,420 --> 00:07:28,480 And it turns red, because I have 141 141 00:07:28,480 --> 00:07:30,913 a special VS code extension for that. 142 142 00:07:31,820 --> 00:07:34,000 And let's say I also have now some error 143 143 00:07:36,610 --> 00:07:37,613 here in the model. 144 144 00:07:38,890 --> 00:07:41,740 Okay, and so this is just to simulate 145 145 00:07:41,740 --> 00:07:44,860 that we introduced some real bucks. 146 146 00:07:44,860 --> 00:07:47,980 So if you wanted to go back on all of these files 147 147 00:07:47,980 --> 00:07:49,690 to the previous commit, 148 148 00:07:49,690 --> 00:07:54,690 then you could simply write git reset, 149 149 00:07:54,830 --> 00:07:59,180 then dash dash, hard, and then HEAD, 150 150 00:07:59,180 --> 00:08:01,300 all in uppercase like this. 151 151 00:08:01,300 --> 00:08:03,490 And now watch what happens to this file 152 152 00:08:03,490 --> 00:08:05,193 as this command is executed. 153 153 00:08:07,400 --> 00:08:09,780 So, you see that it's gone. 154 154 00:08:09,780 --> 00:08:13,090 And to two files here that previously had the M, 155 155 00:08:13,090 --> 00:08:16,620 for modified, are also now back to normal. 156 156 00:08:16,620 --> 00:08:20,850 And debug that we introduced here, is also gone. 157 157 00:08:20,850 --> 00:08:23,740 All right, and so this is the easiest way 158 158 00:08:23,740 --> 00:08:28,460 to going back in time, basically, to the previous commit. 159 159 00:08:28,460 --> 00:08:31,503 But now, let's say that you actually had already committed. 160 160 00:08:33,150 --> 00:08:35,680 So let's say that here, you now had an alert, 161 161 00:08:35,680 --> 00:08:38,470 which says, hacked. 162 162 00:08:38,470 --> 00:08:41,360 And it doesn't really matter what code it is. 163 163 00:08:41,360 --> 00:08:43,280 But let's say this is another bug 164 164 00:08:43,280 --> 00:08:45,990 that you introduced for some reason. 165 165 00:08:45,990 --> 00:08:49,223 But you didn't really notice that it was happening. 166 166 00:08:50,400 --> 00:08:51,793 So let's say here as well. 167 167 00:08:53,450 --> 00:08:55,010 All right, so you see now 168 168 00:08:55,010 --> 00:08:56,903 these two files are modified. 169 169 00:08:58,750 --> 00:09:02,160 And now you want to commit these changes. 170 170 00:09:02,160 --> 00:09:04,790 So you think you added a great new feature. 171 171 00:09:04,790 --> 00:09:07,780 But actually, you just introduced a bug, 172 172 00:09:07,780 --> 00:09:10,380 which allows users to get hacked. 173 173 00:09:10,380 --> 00:09:13,640 But anyway, you don't know that yet, let's say. 174 174 00:09:13,640 --> 00:09:17,370 And so you add all the files to the staging area, 175 175 00:09:17,370 --> 00:09:20,160 and then you do git commit 176 176 00:09:21,260 --> 00:09:25,103 with the message of new feature. 177 177 00:09:27,590 --> 00:09:31,853 Okay, and so now these modified here are gone. 178 178 00:09:32,750 --> 00:09:35,190 And our code is now committed. 179 179 00:09:35,190 --> 00:09:37,700 Now, let's say you keep working on the code. 180 180 00:09:37,700 --> 00:09:41,230 But eventually you notice that you have these bugs here, 181 181 00:09:41,230 --> 00:09:43,740 which allow users to get hacked. 182 182 00:09:43,740 --> 00:09:46,200 And so you want to basically now delete 183 183 00:09:46,200 --> 00:09:49,170 the last commit that you did, right? 184 184 00:09:49,170 --> 00:09:51,493 So you want to go back to the previous commit. 185 185 00:09:52,580 --> 00:09:53,440 So to do that, 186 186 00:09:53,440 --> 00:09:56,960 you need to take a look at that previous commit 187 187 00:09:56,960 --> 00:10:00,973 and you can do git log for that. 188 188 00:10:02,160 --> 00:10:04,130 So here you have basically a log 189 189 00:10:04,130 --> 00:10:06,990 of all the commits that you did. 190 190 00:10:06,990 --> 00:10:08,660 So this one is the last one. 191 191 00:10:08,660 --> 00:10:09,853 So the new feature. 192 192 00:10:12,530 --> 00:10:15,210 And it has basically this ID here. 193 193 00:10:15,210 --> 00:10:17,990 And so this has currently the head. 194 194 00:10:17,990 --> 00:10:19,310 And so that's why previously 195 195 00:10:19,310 --> 00:10:22,960 we could reset using this head keyword. 196 196 00:10:22,960 --> 00:10:25,380 But now you want to go back to this commit, 197 197 00:10:25,380 --> 00:10:28,490 so to the initial commit, right? 198 198 00:10:28,490 --> 00:10:32,700 And so let's copy this ID here, basically. 199 199 00:10:32,700 --> 00:10:35,960 And it would be enough to take the last seven here, 200 200 00:10:35,960 --> 00:10:38,790 but I like to simply copy everything. 201 201 00:10:38,790 --> 00:10:40,740 So select and copy. 202 202 00:10:40,740 --> 00:10:43,740 And now to get out of this log here, 203 203 00:10:43,740 --> 00:10:46,853 you need to type a Q, so Q for quit. 204 204 00:10:47,870 --> 00:10:51,070 Okay, so Ctrl C will not work there, 205 205 00:10:51,070 --> 00:10:53,700 you have to use key like this. 206 206 00:10:53,700 --> 00:10:56,993 And sometimes you even need like, colon and Q. 207 207 00:10:58,140 --> 00:11:02,690 But anyway, let's now do again, git reset, 208 208 00:11:02,690 --> 00:11:06,173 hard, and then the ID of that commit. 209 209 00:11:07,400 --> 00:11:08,273 So let's see. 210 210 00:11:09,180 --> 00:11:12,389 And now that hacked log is gone from here, 211 211 00:11:12,389 --> 00:11:14,530 and from here as well. 212 212 00:11:14,530 --> 00:11:18,450 And so we are now back in that initial commit. 213 213 00:11:18,450 --> 00:11:22,020 And indeed, that's what is set right here. 214 214 00:11:22,020 --> 00:11:24,703 So the head is now at the initial commit. 215 215 00:11:25,760 --> 00:11:29,070 However, moving between commits like this 216 216 00:11:29,070 --> 00:11:30,590 is a little bit dangerous. 217 217 00:11:30,590 --> 00:11:34,400 And so instead, when we plan on doing a lot of changes, 218 218 00:11:34,400 --> 00:11:37,313 usually, we simply create a new branch. 219 219 00:11:38,180 --> 00:11:42,400 So let's write git branch. 220 220 00:11:42,400 --> 00:11:43,820 And this will simply list 221 221 00:11:43,820 --> 00:11:46,570 all the branches that we currently have. 222 222 00:11:46,570 --> 00:11:49,640 And so right now, we only have the master branch. 223 223 00:11:49,640 --> 00:11:53,030 And the star here means that that's the branch 224 224 00:11:53,030 --> 00:11:54,950 that we are currently in. 225 225 00:11:54,950 --> 00:11:57,773 And now again, to close this, you need to write a Q. 226 226 00:12:00,190 --> 00:12:04,320 Okay, but now let's create a new branch. 227 227 00:12:04,320 --> 00:12:06,840 And so that new branch is then basically 228 228 00:12:06,840 --> 00:12:09,980 going to be a copy of the current master branch, 229 229 00:12:09,980 --> 00:12:13,940 in which we can develop new codes and adding new features, 230 230 00:12:13,940 --> 00:12:15,790 but without affecting the codes 231 231 00:12:15,790 --> 00:12:17,770 that is in the master branch. 232 232 00:12:17,770 --> 00:12:20,170 So it's basically a parallel track 233 233 00:12:20,170 --> 00:12:22,300 in which we can develop new code, 234 234 00:12:22,300 --> 00:12:26,000 but without affecting the original code that we had before, 235 235 00:12:26,000 --> 00:12:28,750 and which we knew was already working. 236 236 00:12:28,750 --> 00:12:31,420 And so this is a great way of preventing bugs 237 237 00:12:31,420 --> 00:12:33,830 in our main code base. 238 238 00:12:33,830 --> 00:12:35,463 So we create a new branch, 239 239 00:12:36,960 --> 00:12:40,223 by writing again, git branch, but then here, 240 240 00:12:40,223 --> 00:12:44,400 we can also specify now the name of the branch. 241 241 00:12:44,400 --> 00:12:47,683 So let's call this one new-feature. 242 242 00:12:48,850 --> 00:12:51,510 Okay, so we created a new branch, 243 243 00:12:51,510 --> 00:12:54,890 but we didn't switch to that new branch yet. 244 244 00:12:54,890 --> 00:12:56,840 So to switch to that branch, 245 245 00:12:56,840 --> 00:13:01,823 we write git checkout, and then the name of the branch. 246 246 00:13:05,240 --> 00:13:08,393 And so it says switched to branch new feature. 247 247 00:13:09,850 --> 00:13:12,460 So let's quickly add some modifications here, 248 248 00:13:12,460 --> 00:13:14,053 let's add a new function. 249 249 00:13:17,073 --> 00:13:19,656 Newfeature is simply a function 250 250 00:13:23,790 --> 00:13:25,520 which logs to the console 251 251 00:13:26,690 --> 00:13:31,113 Welcome to the application. 252 252 00:13:33,810 --> 00:13:37,290 Okay, and we also delete this code from here. 253 253 00:13:37,290 --> 00:13:40,943 And then we want to call that function down here. 254 254 00:13:41,840 --> 00:13:43,660 So, nothing significant. 255 255 00:13:43,660 --> 00:13:45,860 This is again, just to simulate. 256 256 00:13:45,860 --> 00:13:48,770 So this one turned now a green 257 257 00:13:48,770 --> 00:13:51,770 because we changed something from the original code. 258 258 00:13:51,770 --> 00:13:55,610 And here it is orange, because we changed something. 259 259 00:13:55,610 --> 00:13:58,260 And if we were to delete something, for example, 260 260 00:13:58,260 --> 00:14:03,260 then it should turn red, which right now is not happening. 261 261 00:14:03,798 --> 00:14:05,560 But anyway, if we click here, 262 262 00:14:05,560 --> 00:14:08,900 we can see exactly what the code looked like before. 263 263 00:14:08,900 --> 00:14:10,573 So these two lines of code are gone 264 264 00:14:10,573 --> 00:14:12,143 and this one is new. 265 265 00:14:12,990 --> 00:14:15,690 And so this in itself, can be very handy 266 266 00:14:15,690 --> 00:14:17,783 and a great use case of Git. 267 267 00:14:19,090 --> 00:14:22,763 But anyway, let's put this very important line here back. 268 268 00:14:24,040 --> 00:14:29,040 Okay, and so let's now add this change to the staging area. 269 269 00:14:30,720 --> 00:14:34,240 So Git add all. 270 270 00:14:34,240 --> 00:14:37,300 So we always have to do this before committing, 271 271 00:14:37,300 --> 00:14:41,433 and then git commit message, 272 272 00:14:42,880 --> 00:14:47,213 then edit new welcome feature. 273 273 00:14:49,481 --> 00:14:52,460 All right, and that's it. 274 274 00:14:52,460 --> 00:14:54,770 So we just created a new feature, 275 275 00:14:54,770 --> 00:14:59,770 but this new feature is now in this new feature brand. 276 276 00:15:00,130 --> 00:15:02,550 So let's check that out again. 277 277 00:15:02,550 --> 00:15:04,983 So git branch, 278 278 00:15:06,080 --> 00:15:08,070 and so now we have these two branches. 279 279 00:15:08,070 --> 00:15:11,960 So master and new feature, and this one is the current one. 280 280 00:15:11,960 --> 00:15:14,453 Then again, Q to Exodus. 281 281 00:15:15,670 --> 00:15:20,320 And now once we are done with this new imaginary feature, 282 282 00:15:20,320 --> 00:15:22,780 let's switch back to the master branch, 283 283 00:15:22,780 --> 00:15:25,570 so that we can then integrate these changes 284 284 00:15:25,570 --> 00:15:27,690 into our main code base. 285 285 00:15:27,690 --> 00:15:30,640 So which again, is in the master branch. 286 286 00:15:30,640 --> 00:15:35,640 So that is git checkout, and master. 287 287 00:15:36,220 --> 00:15:38,310 And so now, as I execute this, 288 288 00:15:38,310 --> 00:15:41,530 you will see this code here going away, 289 289 00:15:41,530 --> 00:15:44,080 because that is the way the code looked like 290 290 00:15:44,080 --> 00:15:46,210 in the master branch. 291 291 00:15:46,210 --> 00:15:48,300 Okay, and so this proves 292 292 00:15:48,300 --> 00:15:51,920 that there are now really like two different tracks 293 293 00:15:51,920 --> 00:15:54,550 with different versions of the code. 294 294 00:15:54,550 --> 00:15:56,647 So in the master branch, we have this code. 295 295 00:15:56,647 --> 00:16:00,620 And in the other branch, we have that code that we just saw, 296 296 00:16:00,620 --> 00:16:02,900 and that just disappeared. 297 297 00:16:02,900 --> 00:16:06,590 But now we can then merge these changes together. 298 298 00:16:06,590 --> 00:16:08,760 So when we are in the branch 299 299 00:16:08,760 --> 00:16:12,210 into which we want to add the new code, 300 300 00:16:12,210 --> 00:16:16,880 we can use Git merge, and then the name of the branch, 301 301 00:16:16,880 --> 00:16:18,990 which contains the new code 302 302 00:16:18,990 --> 00:16:21,960 that we want to merge with the current branch. 303 303 00:16:21,960 --> 00:16:25,370 And so that is the new feature branch. 304 304 00:16:25,370 --> 00:16:28,373 And so now watch what happens here. 305 305 00:16:30,928 --> 00:16:35,670 Okay, so you see that this code here was just added. 306 306 00:16:35,670 --> 00:16:39,170 And down here is also this small summary. 307 307 00:16:39,170 --> 00:16:42,270 So you see, there were six modifications, 308 308 00:16:42,270 --> 00:16:45,300 five additions, so five lines were added, 309 309 00:16:45,300 --> 00:16:46,943 and one line was deleted. 310 310 00:16:47,870 --> 00:16:50,270 And now just to make sure that our working tree 311 311 00:16:50,270 --> 00:16:51,830 is still clean, 312 312 00:16:51,830 --> 00:16:53,980 so that we don't have to commit anything, 313 313 00:16:53,980 --> 00:16:58,050 let's again watch git status. 314 314 00:16:58,050 --> 00:17:00,110 And you see there is nothing to commit, 315 315 00:17:00,110 --> 00:17:02,280 the working tree is clean. 316 316 00:17:02,280 --> 00:17:04,800 And so the code that we have in this branch, 317 317 00:17:04,800 --> 00:17:06,200 so in the master branch, 318 318 00:17:06,200 --> 00:17:09,860 is now the same as in the new feature branch. 319 319 00:17:09,860 --> 00:17:14,860 Okay, so this is a great feature to basically build code, 320 320 00:17:15,080 --> 00:17:17,880 but without affecting our original code, 321 321 00:17:17,880 --> 00:17:22,080 which might break with the changes that we are introducing. 322 322 00:17:22,080 --> 00:17:25,620 And so usually, we never work in the master branch, 323 323 00:17:25,620 --> 00:17:28,930 and simply add features in a different new branch. 324 324 00:17:28,930 --> 00:17:30,600 And then once we're done, 325 325 00:17:30,600 --> 00:17:33,170 we merge these two branches together. 326 326 00:17:33,170 --> 00:17:36,960 And then if there is some error, or something not working, 327 327 00:17:36,960 --> 00:17:40,350 we can always go back to what it was before. 328 328 00:17:40,350 --> 00:17:43,330 All right, and that's all I had to show you 329 329 00:17:43,330 --> 00:17:45,873 in this short introduction to Git. 330 330 00:17:46,900 --> 00:17:49,090 And if you want to learn even more, 331 331 00:17:49,090 --> 00:17:52,860 or maybe have all of these commands that I just showed you, 332 332 00:17:52,860 --> 00:17:54,520 in one nice overview, 333 333 00:17:54,520 --> 00:17:58,240 there's actually a very handy cheat sheet forget, 334 334 00:17:58,240 --> 00:18:02,093 that was developed by GitHub, which I really like to use. 335 335 00:18:03,220 --> 00:18:05,527 So let's search for GitHub, 336 336 00:18:08,380 --> 00:18:11,523 Git Cheat Sheet. 337 337 00:18:13,470 --> 00:18:16,423 Okay, and this one is probably it. 338 338 00:18:18,630 --> 00:18:21,180 This one looks a bit different than the one I mean. 339 339 00:18:23,190 --> 00:18:25,500 Yeah, this is the one that I have. 340 340 00:18:25,500 --> 00:18:27,920 And actually, when I first found this, 341 341 00:18:27,920 --> 00:18:31,370 I even printed this out and put it on my desk, 342 342 00:18:31,370 --> 00:18:34,303 because there's a lot of stuff that we can do. 343 343 00:18:35,620 --> 00:18:39,660 So here is what I just showed you with the branches, right? 344 344 00:18:39,660 --> 00:18:43,073 Then here is Git status, Git add, Git init. 345 345 00:18:45,100 --> 00:18:48,793 And, yeah, also Git reset-hard. 346 346 00:18:51,090 --> 00:18:54,720 And so you see, there is a lot of stuff that we can do. 347 347 00:18:54,720 --> 00:18:55,900 And in the next video, 348 348 00:18:55,900 --> 00:18:59,930 we will then actually use these commands here. 349 349 00:18:59,930 --> 00:19:03,520 So Git push and Git pull, 350 350 00:19:03,520 --> 00:19:05,660 so that we can basically copy 351 351 00:19:05,660 --> 00:19:08,760 our local repository onto a repository 352 352 00:19:08,760 --> 00:19:11,790 that lives in the cloud on GitHub. 353 353 00:19:11,790 --> 00:19:15,150 And this will then allow us to basically keep a backup 354 354 00:19:15,150 --> 00:19:17,820 of our repository online. 355 355 00:19:17,820 --> 00:19:21,080 And it will also enable us to automatically deploy 356 356 00:19:21,080 --> 00:19:23,590 or site from this repository 357 357 00:19:23,590 --> 00:19:26,903 by setting up continuous integration on Netlify. 358 358 00:19:27,790 --> 00:19:30,070 And so let's learn how to do that. 359 359 00:19:30,070 --> 00:19:34,003 So how to push our code to GitHub right in the next lecture. 31081

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.