1
00:00:02,810 --> 00:00:08,320
Havior one Mark Price your dead slopes dot com and today we're going to talk about version control specifically

2
00:00:08,380 --> 00:00:09,640
about get.

3
00:00:09,910 --> 00:00:12,770
So let's get started.

4
00:00:12,850 --> 00:00:18,820
What I'm going to show you is kind of how version control works and I want to give you a tip from now

5
00:00:18,820 --> 00:00:24,010
on in here into the far future as your development career progresses.

6
00:00:24,220 --> 00:00:28,890
If you are not using version control on every single project you are doing it wrong.

7
00:00:28,990 --> 00:00:33,790
OK I don't want to ever see you creating a project that doesn't have version control in some form or

8
00:00:33,790 --> 00:00:34,320
fashion.

9
00:00:34,410 --> 00:00:34,700
OK.

10
00:00:34,720 --> 00:00:35,460
That is the law.

11
00:00:35,470 --> 00:00:37,480
Put it in right now in your brain.

12
00:00:37,540 --> 00:00:39,810
Always always always use version control.

13
00:00:39,990 --> 00:00:40,720
OK.

14
00:00:41,320 --> 00:00:44,170
Not to be confused with birth control or things like that.

15
00:00:44,170 --> 00:00:46,470
This is actually really important.

16
00:00:46,720 --> 00:00:50,250
So what is version control.

17
00:00:50,580 --> 00:00:52,120
Well let's talk about code here.

18
00:00:52,120 --> 00:00:56,110
OK so you write code and it creates programs.

19
00:00:56,170 --> 00:00:58,000
So let's talk about a document.

20
00:00:58,090 --> 00:00:59,620
Let's say we've got this document here.

21
00:00:59,710 --> 00:01:00,180
OK.

22
00:01:00,220 --> 00:01:01,380
It's an ugly document.

23
00:01:01,450 --> 00:01:02,380
It's OK.

24
00:01:02,860 --> 00:01:04,370
This is your document.

25
00:01:04,910 --> 00:01:09,820
OK you've written some code on it and actually it doesn't you have to be code it could be anything could

26
00:01:09,820 --> 00:01:12,600
be a text or whatever but we're going to talk about code.

27
00:01:12,610 --> 00:01:14,420
So you've written some code here.

28
00:01:14,630 --> 00:01:15,430
OK.

29
00:01:15,850 --> 00:01:19,810
Now if you're only one person and if you're working by yourself that's fine.

30
00:01:19,960 --> 00:01:23,640
You keep making changes to this and no one cares right.

31
00:01:23,650 --> 00:01:29,920
You can just keep adding and changing it all that you want how ever what happens if maybe somewhere

32
00:01:29,950 --> 00:01:30,730
right here.

33
00:01:30,880 --> 00:01:32,350
You broke something.

34
00:01:32,590 --> 00:01:33,450
OK.

35
00:01:33,880 --> 00:01:41,250
And then now your 5000 lines later today 5000 lines later of code and you just realized you had a big

36
00:01:41,290 --> 00:01:41,940
bug.

37
00:01:42,280 --> 00:01:42,940
OK.

38
00:01:43,300 --> 00:01:47,170
Well now you have to dig through 5000 lines of new code to go back and find this code here.

39
00:01:47,170 --> 00:01:48,230
So this is a problem.

40
00:01:48,280 --> 00:01:51,580
You've just done a lot of work and now you're going to have to do a lot more work to find this bug and

41
00:01:51,580 --> 00:01:52,320
go back.

42
00:01:52,510 --> 00:01:53,170
OK.

43
00:01:53,380 --> 00:01:54,310
This is one problem.

44
00:01:54,310 --> 00:01:57,450
Version control can solve and I'll tell you how to solve it in a second.

45
00:01:57,700 --> 00:01:59,160
Here's the next problem.

46
00:01:59,320 --> 00:02:03,870
OK you've got a few people let's just say to people happy Sam here.

47
00:02:03,970 --> 00:02:04,440
OK.

48
00:02:04,600 --> 00:02:05,940
That's happy Sam.

49
00:02:06,040 --> 00:02:13,110
And this one is beady eyed puppy and he's never really happy.

50
00:02:13,350 --> 00:02:13,980
OK.

51
00:02:14,260 --> 00:02:19,670
So you've got two people here this is Pete this is Sam and they've got their own code files right.

52
00:02:20,230 --> 00:02:22,370
But they're working on the same project.

53
00:02:23,100 --> 00:02:23,770
OK.

54
00:02:24,010 --> 00:02:28,140
So let's say that Sam wants to make some changes to the codebase.

55
00:02:28,310 --> 00:02:30,510
OK so he he makes changes.

56
00:02:30,580 --> 00:02:30,850
OK.

57
00:02:30,850 --> 00:02:33,390
And then Pete makes his own changes.

58
00:02:33,400 --> 00:02:34,020
OK.

59
00:02:34,240 --> 00:02:38,350
Now here's the question this is the same project or building an app together.

60
00:02:38,350 --> 00:02:41,240
How does Sam get his changes over to Pete.

61
00:02:41,950 --> 00:02:44,550
He's made one two three changes and now he's mid-twentieth you change.

62
00:02:44,560 --> 00:02:45,770
Well sounds like OK.

63
00:02:46,090 --> 00:02:50,340
Let's go ahead and load up Dropbox so you know Dropbox maybe you've done this before.

64
00:02:50,350 --> 00:02:51,210
So Dropbox.

65
00:02:51,220 --> 00:02:53,320
And then he handed over to me.

66
00:02:53,320 --> 00:02:54,960
He's like I made some changes.

67
00:02:55,000 --> 00:02:58,720
So Pete now has a new code file so he then opens up the code file.

68
00:02:58,720 --> 00:03:01,380
So he he opens up this code file here.

69
00:03:01,960 --> 00:03:06,100
And then what he does is he grabs the changes he finds all the changes that were made and then he puts

70
00:03:06,100 --> 00:03:07,400
them here in his code.

71
00:03:07,620 --> 00:03:09,460
OK.

72
00:03:09,700 --> 00:03:13,170
And he mixes them in and he's like OK I put your changes in the code now.

73
00:03:13,250 --> 00:03:18,070
Now I need to give you the latest Fosset MP sends over the combination back to Sam.

74
00:03:18,400 --> 00:03:22,000
OK here's the new file with all of Sam and peace changes in it.

75
00:03:22,030 --> 00:03:25,460
And then that's going to go ahead and overwrite this.

76
00:03:25,900 --> 00:03:31,030
And then if you've got a third person here let's say pointy nosed.

77
00:03:31,270 --> 00:03:39,470
Sally joins the project on her beedi angry eyes.

78
00:03:39,520 --> 00:03:41,240
She go up on the wrong side of the bed.

79
00:03:41,410 --> 00:03:43,300
So she now joins the project.

80
00:03:43,510 --> 00:03:49,990
So now you've got people transferring code K to all the different players on the team.

81
00:03:49,990 --> 00:03:51,650
Does that make sense.

82
00:03:51,680 --> 00:03:52,700
We've got this big mess.

83
00:03:52,720 --> 00:03:53,920
Who has the latest version.

84
00:03:53,930 --> 00:03:54,680
Blah blah blah blah.

85
00:03:54,680 --> 00:03:57,930
That's that's how it used to be a long time ago a long time ago.

86
00:03:58,090 --> 00:03:59,570
Do you think that's effective.

87
00:03:59,790 --> 00:04:01,170
Oh that's terrible.

88
00:04:01,180 --> 00:04:02,340
This is all bad.

89
00:04:02,440 --> 00:04:05,720
KATE PLUS it's you're manually taking these changes inserting them.

90
00:04:05,760 --> 00:04:06,880
Oh it's nasty.

91
00:04:06,890 --> 00:04:08,710
So this is not what we want to do.

92
00:04:08,710 --> 00:04:15,220
Problem one is saving your files if you have problems going back and be unable to revert and find those

93
00:04:15,220 --> 00:04:20,210
issues and then you've got this whole issue here with multiple people on the same team.

94
00:04:20,590 --> 00:04:24,650
Thus version control was created.

95
00:04:24,810 --> 00:04:25,530
OK.

96
00:04:25,540 --> 00:04:31,040
And what version of control is the controlling of versions of documents.

97
00:04:31,270 --> 00:04:32,210
OK.

98
00:04:32,470 --> 00:04:38,220
So let's talk about scenario one with your code backup files if someone has used a version control.

99
00:04:38,230 --> 00:04:40,940
Let's go back to Scenario 1 so make a new person here.

100
00:04:41,020 --> 00:04:42,210
Keep it interesting.

101
00:04:42,220 --> 00:04:46,910
This is Jerry and Jerry has code.

102
00:04:47,030 --> 00:04:49,520
And now let's say Jerry's using version control.

103
00:04:49,720 --> 00:04:57,180
So he makes change one day to his document and it's saved changed to it's saved.

104
00:04:57,400 --> 00:04:59,550
And we're going to call these actual commits.

105
00:04:59,560 --> 00:05:01,300
That's the that's the phrase that you'll use.

106
00:05:01,350 --> 00:05:05,970
With version control especially in regards to get so he's making comments right.

107
00:05:05,970 --> 00:05:11,850
So he's committing So what he's doing is every time he's making a change he's now committing to version

108
00:05:11,850 --> 00:05:12,630
control.

109
00:05:12,760 --> 00:05:18,480
It's being committed Now let's say he comes to version for and he finds a bug here it's like oh my gosh

110
00:05:18,870 --> 00:05:20,030
what's going on here.

111
00:05:20,220 --> 00:05:23,620
Well now what he can do is he can go check out.

112
00:05:23,880 --> 00:05:25,250
It's called checking out.

113
00:05:25,410 --> 00:05:27,740
You know like when you're checking out a girl.

114
00:05:28,470 --> 00:05:30,160
Whatever.

115
00:05:30,480 --> 00:05:33,030
Except in this case you're checking out code.

116
00:05:33,240 --> 00:05:34,360
Not really related.

117
00:05:34,360 --> 00:05:39,270
Anyway he's checking out where he wants to check out a previous commit because he wants to locate worst

118
00:05:39,300 --> 00:05:41,690
problem is what he can do is he can actually check out.

119
00:05:41,820 --> 00:05:47,400
Let's say right here number three and then he can run his code his code is restored back to that previous

120
00:05:47,400 --> 00:05:50,800
version and he can say OK the bug still exists here.

121
00:05:50,940 --> 00:05:52,220
So that is not it happened.

122
00:05:52,230 --> 00:05:57,900
And then he can check out another one another previous commit and he's like OK the bug is gone here.

123
00:05:57,900 --> 00:06:03,900
So then what he can do is he can analyze the differences between those two cochain does he doesn't have

124
00:06:03,900 --> 00:06:08,040
to go back to the five thousand lines of code if I were the problem is he can analyze it between the

125
00:06:08,040 --> 00:06:11,770
last two changes there where his problem was and let's say that it was a small problem.

126
00:06:11,850 --> 00:06:13,220
Well he may not want to fix it here.

127
00:06:13,260 --> 00:06:17,070
He can go back up here but he knows where it is now and then he can go fix that problem or he could

128
00:06:17,070 --> 00:06:19,400
just take it out of this altogether.

129
00:06:19,530 --> 00:06:24,440
And then you might have cascading problems down through here but regardless the point is you can now

130
00:06:24,510 --> 00:06:28,680
easily solve his problem because he can check out previous versions of his code.

131
00:06:29,010 --> 00:06:32,250
Also this is important here besides just checking our previous code.

132
00:06:32,250 --> 00:06:34,140
This allows you to have multiple versions.

133
00:06:34,230 --> 00:06:36,140
OK multiple versions of your application.

134
00:06:36,180 --> 00:06:37,550
It's like saving backups right.

135
00:06:37,620 --> 00:06:38,310
Saving backup.

136
00:06:38,320 --> 00:06:39,660
That's what this is so this is safe.

137
00:06:39,660 --> 00:06:42,820
This is much better than the first scenario we're talking about.

138
00:06:43,010 --> 00:06:43,790
OK.

139
00:06:44,130 --> 00:06:46,970
Now let's talk about the other scenario where we have multiple people.

140
00:06:47,010 --> 00:06:47,620
OK.

141
00:06:47,770 --> 00:06:49,830
So this guy here.

142
00:06:49,980 --> 00:06:50,790
So happy.

143
00:06:50,910 --> 00:06:52,010
He loves the code.

144
00:06:52,110 --> 00:06:52,510
All right.

145
00:06:52,530 --> 00:06:54,160
And he's got his code here.

146
00:06:54,900 --> 00:06:56,320
And then let's go over here.

147
00:06:56,730 --> 00:07:03,020
And this guy's name is Sam too but this is sinister.

148
00:07:03,090 --> 00:07:09,240
Sam he plays online games and thinks is real cool but I have the handle games at his code.

149
00:07:09,270 --> 00:07:18,750
And then what we've got down here is you've got this guy and this is Harry and Harry has his own code

150
00:07:18,770 --> 00:07:21,070
to say how do we solve this problem.

151
00:07:21,090 --> 00:07:23,930
You have any ideas where does version control come into play.

152
00:07:24,000 --> 00:07:25,490
Well let's take a look at this.

153
00:07:25,500 --> 00:07:28,440
So let's say Jim mix changes 1 2 and 3.

154
00:07:29,100 --> 00:07:33,440
And since Tristan mainstreams is one two and three and let's all say Harry.

155
00:07:33,780 --> 00:07:37,760
Well Harry sucks at coding so he only made one change and it wasn't really good.

156
00:07:38,310 --> 00:07:44,240
And anyway so you've got these three these three people here i'm just had sucks Coney's practice you

157
00:07:44,250 --> 00:07:48,640
get better over time and you're like thanks for de-motivating me.

158
00:07:49,050 --> 00:07:50,220
So they've all made their changes right.

159
00:07:50,220 --> 00:07:53,080
Remember how before we had to swap documents all that kind of stuff.

160
00:07:53,080 --> 00:07:57,460
Well now what we can do is Jim can now commit.

161
00:07:57,520 --> 00:08:00,340
OK so he's made these three commits these three Kamisese treatments.

162
00:08:00,360 --> 00:08:01,990
He can push them up to a server.

163
00:08:02,130 --> 00:08:02,580
OK.

164
00:08:02,730 --> 00:08:05,530
Or some location whatever it doesn't matter it's it's arbitrary.

165
00:08:05,530 --> 00:08:10,540
The location is arbitrary but let's just call this the business call this the server for right now.

166
00:08:10,710 --> 00:08:11,210
OK.

167
00:08:11,310 --> 00:08:14,680
So what he can actually do is he can push these changes here.

168
00:08:14,940 --> 00:08:15,610
OK.

169
00:08:15,840 --> 00:08:20,180
And then what happened is that he can actually pull down those changes.

170
00:08:20,310 --> 00:08:22,880
OK so he can recall this kush.

171
00:08:22,950 --> 00:08:25,660
So Jim can push sinister Samkon.

172
00:08:25,670 --> 00:08:31,380
Paul what happens is it's going to pull those changes and what it's going to do is it's going to automatically

173
00:08:31,590 --> 00:08:36,810
inject those changes where they need to go in Sam's code automatically he's going to inject them in

174
00:08:36,810 --> 00:08:37,420
there.

175
00:08:37,590 --> 00:08:42,690
And if there's no conflict meaning if no one edited the same line of code at the same time it's called

176
00:08:42,690 --> 00:08:46,360
a merge conflict we'll talk about that later on in the lessons.

177
00:08:46,410 --> 00:08:49,990
But if you automatically inject them right in there.

178
00:08:50,430 --> 00:08:50,920
That's cool.

179
00:08:50,950 --> 00:08:51,620
Now that's Paul.

180
00:08:51,630 --> 00:08:57,000
And now with those things merge this is called Amerge so centrist that sinister stamp has now merged

181
00:08:57,390 --> 00:08:58,890
those changes merged.

182
00:08:58,920 --> 00:09:04,710
Now what he can do is he can actually push the merge back to the server so the server is now up to date

183
00:09:04,830 --> 00:09:07,340
with gyms and or stamps code.

184
00:09:07,350 --> 00:09:08,550
And now Harry.

185
00:09:08,650 --> 00:09:09,100
OK.

186
00:09:09,150 --> 00:09:11,550
He can actually pull down all of their changes.

187
00:09:11,550 --> 00:09:14,600
So he's polling and that's going to inject them all in here.

188
00:09:14,610 --> 00:09:16,070
Boom boom boom boom.

189
00:09:16,470 --> 00:09:17,120
OK.

190
00:09:17,340 --> 00:09:22,330
And then once those are merged Harry can now push all the changes back up.

191
00:09:22,350 --> 00:09:25,380
And now the server has everyone's code changes.

192
00:09:25,380 --> 00:09:28,080
No one had to swap files in to happen automatically.

193
00:09:28,080 --> 00:09:32,370
The pushing in the polling like I drew it out here but really you could literally if off if everything

194
00:09:32,370 --> 00:09:35,010
worked out the way it was you could literally make the changes.

195
00:09:35,010 --> 00:09:38,580
Pull down someone else's change just merge them in and push them back and you could do that within a

196
00:09:38,580 --> 00:09:41,950
couple of minutes for less seconds even.

197
00:09:42,060 --> 00:09:47,070
So we went from this massively crazy process of managing people's code to working automatically.

198
00:09:47,070 --> 00:09:50,760
Everyone's so happy even sinners Sam is starting to break out a smile.

199
00:09:51,010 --> 00:09:51,570
OK.

200
00:09:51,750 --> 00:09:54,750
Devious smile but because you put a bug in the code.

201
00:09:54,750 --> 00:09:55,630
But anyway.

202
00:09:55,980 --> 00:09:58,520
So version control very very powerful.

203
00:09:58,560 --> 00:09:59,080
OK.

204
00:09:59,220 --> 00:10:05,380
Never ever ever ever ever write any code any more on any project if you don't have birth control and

205
00:10:05,380 --> 00:10:10,060
of course the most popular version control system right now is called Get G-I.

206
00:10:10,090 --> 00:10:17,710
There are other systems such as mercurial perforce SVM things like that and some larger companies are

207
00:10:17,710 --> 00:10:22,630
still using those but get is blowing away the world right now it's fantastic.

208
00:10:22,780 --> 00:10:24,740
And that's what we're using in these lessons here.

209
00:10:25,030 --> 00:10:27,640
And it's not that hard.

210
00:10:27,700 --> 00:10:30,430
Even a beginner can get up and running with it fairly quick.

211
00:10:30,520 --> 00:10:38,080
So that's version control that to get started to make sense started to dig your brain wrapper around

212
00:10:38,080 --> 00:10:39,010
the concept.

213
00:10:39,040 --> 00:10:44,470
In the end what I want to think about is just imagine having multiple versions of a file and a system

214
00:10:44,470 --> 00:10:47,430
that manages that for you so you never have to copy and paste again.

215
00:10:47,560 --> 00:10:52,300
And because the more you have to do copying and pasting the more error prone your code becomes and you

216
00:10:52,300 --> 00:10:54,170
never ever want any code.

217
00:10:54,250 --> 00:10:54,760
So that's it.

218
00:10:54,760 --> 00:11:00,810
Mark Price and def slopes duck come forward and remember to get your free life help.

219
00:11:00,840 --> 00:11:05,020
Dennis Lopes dot com and click on the chat room with thousands of students and they're helping each

220
00:11:05,020 --> 00:11:05,880
other out.

221
00:11:05,890 --> 00:11:07,150
Also click on the forums.

222
00:11:07,150 --> 00:11:09,730
This is where you can search for answers to your coat problems.

223
00:11:09,730 --> 00:11:11,190
You can also post your own issues.

224
00:11:11,300 --> 00:11:12,070
So head on over now.
