Hate everyone.
Mark Price your debt slopes dot com and today we're going to talk about version control specifically
about get.
So let's get started.
What I'm going to show you is kind of how version control works.
And I want to give you a tip from now on in here into the far future as your development career progresses.
If you are not using version control on every single project you are doing it wrong.
OK I don't want to ever see you creating a project that doesn't have rigid control in some form or fashion.
OK.
That is the law.
Put it in right now in your brain.
Always always always use version control.
OK.
Not to be confused with birth control or things like that.
This is actually really important.
So what is birth control.
Well let's talk about code here.
OK so you write code and exchange programs.
So let's talk about a document.
Let's say we've got this document here.
OK.
It's an ugly document.
It's OK.
This is your document.
OK you've written some code on it and actually it doesn't you have to be code it could be anything could
be a text or whatever but we're going to talk about code.
So you've written some code here.
OK.
Now if you're only one person and if you're working by yourself that's fine.
You keep making changes to this and no one cares right.
You just keep adding and changing it all that you want.
How ever what happens if maybe somewhere right here you broke something.
OK.
And then now your 5000 lines later today 5000 lines later of code and you just realized you had a big
bug.
OK.
Well now you have to dig through 5000 lines of new code to go back and find this coding.
So this is a problem.
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
go back.
OK.
This is one problem.
Version control can solve and I'll tell you how to solve it in a second.
Here's the next problem.
OK you've got a few people let's just say to people happy Sam here.
OK that's happy Sam.
And this one is beady eyed puppy and he's never really happy.
OK.
So you've got two people here this is Pete this is Sam and they've got their own code files right.
But they're working on the same project.
OK.
So let's say that Sam wants to make some changes to the code base.
OK so he he makes changes.
OK.
And then Pete makes his own changes.
OK.
Now here's the question this is the same project or building an app together.
How does Sam get his changes over to Pete.
He's made one two three changes and now he's mid-twentieth you change.
Well sounds like.
OK.
Let's go ahead and load up Dropbox so you know Dropbox you maybe you've done this before.
So draw box and then he handed it over to me like I made some changes.
So Pete now has a new code file so he then opens up the code file.
So he he opens up this code file here.
And then what he does is he grabs the changes he finds all the changes that were made and then he puts
them here in his code.
OK.
And he mixes them in and he's like OK I put your changes in the code.
Now now I need to give you the latest Fosset MP sends over the combination back to Sam.
OK here's the new file with all of Sam and these changes in it.
And then that's going to go ahead and overwrite this.
And then if you've got a third person here let's say pointy nosed.
Sally joins the project on her B-D angry eyes.
She will go up on the wrong side of the bed.
So she now joins the project.
So now you've got people transferring code OK to all the different players on the team.
Does that make sense.
And we've got this big mess.
Who has the latest version.
Blah blah blah blah.
That's that's how it used to be a long time ago a long time ago.
Do you think that's effective.
Oh that's terrible.
This is all bad.
KATE PLUS you're manually taking these changes inserting them.
Oh it's nasty.
So this is not what we want to do.
Problem one is saving your files if you have problems going back and be unable to revert and find those
issues.
And then you've got this whole issue here with multiple people on the same team DOS version control
was created.
OK.
And what version control is is the controlling of versions of documents.
OK so let's talk about scenario one with your code backup files if someone has used a version control.
Let's go back to Scenario 1 so make a new person here.
Keep it interesting.
This is Jerry.
And Jerry has code.
And now let's say Jerry's using version control.
So he makes change one day to his document and it's saved changed to it's saved.
And we're going to call these actual committees.
That's the that's a phrase that you'll use with version troll especially in regards to get.
So he's making comments right.
So he's committing.
So what he's doing is every time he's making a change he's now committing to version control.
It's being committed Now let's say he comes a version for and he finds a bug here it's like oh my gosh
what's going on here.
Well now what he can do is he can go check out.
It's called checking out.
You know like when you're checking out a girl.
Whatever.
Except in this case you're checking out code.
Not really related.
Anyway he's checking out where he wants to check out a previous commit because he wants to locate worst
problem is what he can do is he can actually check out.
Let's say right here number three.
And then he can run his code his code is restored back to that previous version and he can say OK the
bug still exists here.
So that is not where it happened.
And then he can check out another one another previous commit and he's like OK the bug is gone here.
So then what he can do is he can analyze the differences between those two cochain does he doesn't have
to go back to the 5000 lines of code to find where the problem is.
He can analyze it between the last two changes there where his problem was and let's say that it was
a small problem.
Well he may not want to fix it here he can go back up here but he knows where it is now and then he
can fix that problem or he could just take it out of this altogether.
And then you might have cascading problems down through here.
But regardless the point is you can now easily solve his problem because he can check out previous versions
of his code.
Also this is important here besides just checking our previous code.
This allows you to have multiple versions.
OK multiple versions of your application.
It's like saving backups right.
Saving backups.
That's what this is so this is safe.
This is much better than the first scenario we're talking about.
OK.
Now let's talk about the other scenario where we have multiple people.
OK.
So this guy here so happy.
He loves the code.
All right.
And he's got his code here.
And then let's go over here.
And this guy's name is Sam too.
But this is sinister Sam.
He plays online games and thinks is real cool but I have the handle his code.
And then what we've got down here is you've got this guy and this is Harry and Harry has his own CO-2.
OK how do we solve this problem.
You have any ideas where does version control come into play.
Well let's take a look at this.
So let's say Jim mix changes 1 2 and 3.
And Senator Sam makes changes one to three.
And let's say Harry.
Well Harry sucks at coding so he only made one change and it wasn't really good.
And anyway so you've got these three these three people here i'm just had no one sucks.
Coney's practice you get better over time.
And you're like thanks for de-motivating me.
So they've all made their changes right.
Remember how before we had to swap documents all that kind of stuff.
Well now what we can do is Jim can now commit.
OK so he's made these three commits these three commits these treatments.
He can now push them up to a server OK or some location whatever it doesn't matter it's arbitrary.
The location is arbitrary but let's just call this the let's just call this the server for right now.
OK.
So what he can actually do is he can push these changes here.
OK.
And then what happened is that he can actually pull down those changes.
OK so he can recall this kush.
So Jim can push sinister Samkon.
Paul what happens is it's going to pull those changes and what it's going to do is it's going to automatically
inject those changes where they need to go in Sam's code automatically he's going to inject them in
there.
And if there's no conflict meaning if no one edited the same line of code at the same time it's called
a merge conflict we'll talk about that later on in the lessons.
But do you automatically and inject them right in there.
That's cool.
Now that's Pold.
And now with those things merge this is called a merge so centrist that sinister Sam has now merged
those changes merged.
Now what he can do is he can actually push the merge back to the server so the server is now up to date
with Jim's and sinister stamps code.
And now Harry.
OK.
He can actually pull down all of their changes.
So he's polling and it's going to inject them all in here.
Boom boom boom boom.
OK.
And then once those are merged Harry can now push all the changes back up.
And now the server has everyone's code changes.
No one had to swap files in to happen automatically.
The pushing in the polling like I drew it out here but really you could literally if everything worked
out the way it was you could literally major changes pull down someone else's change just merge them
in and push them back and you could do that within a couple of minutes for less seconds even so we went
from this massively crazy process of managing people's code to working automatically.
Everyone's so happy even sewer system is starting to break out somehow.
OK.
Devious smile but because you put a bug in the code.
But anyway so version control very very powerful.
OK.
Never ever ever ever ever write any code any more on any project if you don't have birth control and
of course the most popular version control system right now is called Get g t.
There are other systems suggest mercurial perforce SVM things like that and some larger companies are
still using those but get is blowing away the world right now it's fantastic.
And that's what we're using in these lessons here.
And it's not that hard.
Even a beginner can get up and running with it fairly quick.
So that's version control that's get started to make sense starting to get your brain wrapping around
the concept.
What in the end what I want you to think about is just imagine having multiple versions of a file and
a system that manages that for you so you never have to copy and paste again.
And because the more you have to do copying and pasting the more air prone your code becomes and you
never ever want any code.
So that's it.
Mark Price and Dev slopes does come move forward and remember to get your free life help go to death
slopes dot com and click on the chat room with thousands of students and they're helping each other
out.
Also click on the forums this is where you can search for answers to your coproduct.
You can also post your own issues so head on over now.