In this video we're going to talk about get and get hub and source control.
Now you might remember get hub from our previous section where we used it to put the Web site online
but I'll show you that it is so much more than that.
More importantly getting get hub is used by most professional companies and it is a skill that is expected
to be known by all developers now.
So this is an important section one of the first things most developers have to do on their first day
at the job is to MIT something called a pull request which uses get and get help.
We'll get through that.
In this section don't worry you're going to learn all of this and it's going to make sense.
Let's first start with source control.
Up until now we have only worked on small files.
No team members just ourselves.
Just a couple of files.
But in real life you're most likely not the only developer on a team.
Most likely the projects are huge.
There's many many files.
Source control allows us to make sure that multiple people can work on the same file from different
locations.
Think of it as Google Docs that allows people to collaborate on one document but enough talk let's actually
check it out.
I have over here set up two folders.
One is for myself.
Andre who just started a new job but X company and I have MRC here who has been working at the company
for a while and she has project files over here.
I'm actually using the files from our background generator video now without get or get help.
What I can do is just copy and paste these files so I have whatever Marcy has and we can start working
on these files.
I can have my developer environment here with my terminal and my Sublime Text and I can work on whatever
changes that need to be made on the app and Marci over here also has her own version where she can work
on it and we're both working on the same project but let's say that both Marcy and I are working on
this project and she decides to change the project name from gradient background to super background
and at the same time in my project I decide to call this cool background.
Well now you'll have to set up a meeting between myself and Marcy and decide how we should change the
code.
And this is a small example but you can imagine that as different programmers work together there's
always going to be this issue of one person changing one thing and another prison changing.
Another thing.
This is where source control came in and social control is a way to control this where we have one place
instead of our own computers.
And this case is just represented by the folder that I have in here instead of each of us having a copy
of the project with source control.
We have a copy of the project but there is a centralized location up somewhere maybe owned by the company
or somewhere on the Internet that has the ultimate version that we each talk to to make sure that we
each have the same version getting get hub is a way to do this to be able to use source control and
as a matter of fact it's the de facto way of doing this.
So like I said before this is most likely the tool you'll be using every single day at your workplace
so if I go to the github Web site here what it allows us to do is it's a place a central place that
both Andre and Marcy can talk to so even though we work on the same files the same project I can ask
this central location such as GetUp.
Hey has Marcy made any changes.
And Marcy can ask hey has Andre made any changes and every once in a while you'll get something like
this where we have cool background and super background where we have something called a merge conflict
what get Hub allows us to do is say hey I noticed there is a merge conflict I see that you guys have
both changed your background I don't know who's right but here's the information.
Andre Marcy Can you guys talk amongst yourself and figure it out.
That's pretty much workflow.
So let's actually see what this looks like.
The first thing we want to do is set up a github account.
If you haven't done it in the previous exercises you absolutely should start to get hub account.
It's free.
And like I said before if you're a developer you just need to have it it's where everybody puts their
projects it's where you work you'll be spending a lot of time on this Web site.
You might remember that when we had the get Hub project I also told you to get get hub for desktop
although we use that to make things simpler.
During that video this is actually not the recommended way of doing it.
It allows you to visually see and interact with get hub but it's kind of looked down upon by employers
and most people use the terminal or the command prompt to actually do it.
So I won't be teaching you this way just because I think it's bad practice and getting used to the terminal
is important.
I'm going to close that and we're gonna get the start the very first thing we're gonna do is we're going
to click on Start a project and here we're going to call it whatever you want we'll call it background
generator and you also want to leave it as public and we want to click on initialize this with a read
me and we'll click Create repository.
And what that does.
Well we've created a new project on GitHub and here the read me which is just a file that describes
your project.
You can see that it's here.
We can type into the read me whatever we want and I'll describe our project.
But let's go back if Marcy.
Let's say Marcy has been working at this company for a long time.
I'm actually gonna remove my files here.
Marcy has been working at this company for a long time and the employer finally decided hey we need
to use get hub.
We're going to hire this new guy Andre.
We want to make sure that you both can work on it on the project together without any issues.
Can you put the project up on github so what Marcy will do is she will go to get help create background
generator and then she's going to click right over here to clone or download and she's going to make
sure it says use HDD P.S. And from here you just click on this button which copies this link to your
keyboard then Marcy goes to her terminal.
And right now we're in documents we want to have the project in the Marcy folder so I'll C.D. into Marcy
if I click Elyse I see that yet I have my files.
Now the first command that we're going to learn is called Get clone and then copy and paste what we
copy from the Web site.
We're just saying hey clone this project from get hub dot com.
So I press enter and there you go.
Everything is downloaded.
If I go back to the folder now I see that I have a background generator.
If I double click this you'll see that I have a dot get folder here that's actually hidden.
You might not even see it on your laptop if you don't have this feature on your computer enabled but
this dog get now allows me to communicate with GetUp.
So what we can do now.
Marcy can copy and paste these files and put it into the background generator.
Now let me show you the next get command.
Marcy right now if we see she's in her folder but now we need to go into background generator because
if we do any gate commands here.
Well it won't work because it's not a good project.
We need to actually go inside of the project that was created on github.
So I'm going to S.D. into that directory notice here.
I have my terminal set so that it actually shows me what get hub location I'm in and I'll explain one
master means later now that we're here we can look at all our files.
Yep I see that now I have my read me which I created on GitHub plus the files that I copy and pasting
we need to sync this so that if I go into my background generator instead of the read me files Marcy
can put up her files on GitHub the way we do that is our second command get status it tells us that
we have on tracked files that is we have indexed not a Schimmel script yes and style that are on tract
and it says use get ad file to include while you will be committed.
So now that we see our status of what we have in our folder we can say get ad and the file name so I
can do index dot paste email get had script digest and get ad style that CSX.
Let's clear this so we can see it.
And now I can do get status again just to see what our status is.
And now I have your branches up to date changes to be committed.
You see that now with ad we've said hey we want to add these changes.
We have new files that we've added and says to be committed.
So the second step is to do something called Get commit and get commit says hey I'm committing that
these are the changes that I want to make to get hub.
And it allows you to pass a message so that on get happy it'll show the message.
When Andre comes back in he can say oh Marcy added these files and this is the message and we do that
by doing this.
And within here within the double codes I can say adding starting Project close the bracket press Enter
I'm going to clear this.
Now there's one last step.
We've added.
We did get add to add our changes then get commit to commit and say yeah we're locking in those changes.
And then finally we need to let get hub dot com know that these are the changes.
So we do get push
and there you go.
It has now been pushed to this repository.
So if I go back and I refresh look at that it's the same thing that we did when we put up our first
Web site online.
But instead of using the desktop version of Get hub we use the command line and now we have our project
which is very good.
Now let's go back to our example.
So Marcy has been working on this project.
There's a good repository.
And I just joined the company and now I need to start working on this.
What do I do now I need to access GitHub and get the copy of background generator the way I do that.
Well I go into my folder
and I do the same thing I do get clone and then I copy and paste the repository just like before
get clone and clone the repo.
And there you go.
If I go back to my folder look at that I have a background generator so we're both working now on background
generator but not off of each other's files we're working with whatever version is on github.
All right.
So now more realistic we go back to working and on the first day of my job I say I'm going to change
the greenish background title.
Actually the h1 tag to cool generator if I save this and I do get status
Oh well I'm not in a good repository right now if you remember I have to go into background generator.
Let me open that up a bit so you can see.
There you go again.
These get commands won't work if you're not in a folder that has the dot get folder.
So let me do that C.D. into background generator.
I'm going to clear this and I'm going to say get status and look at that.
It tells me that I've modified index not ACM Alpha and if you remember I will say Get had I only have
one file I can do it next dot A.T.M. but if I want it if I had multiple files and I want to just commit
all them on once I can just do the period so I'll do that and then get commit and I'll add a message
changing Title I press enter.
Now clear this.
OK.
And again I do get push and it looks like everything went through.
So let's open that up and check it out.
I now refresh here
and what we haven't seen any changes but we now see that we have three commits.
We have the initial commit the adding back project that MRC did.
And it shows you all the files that were added and if I go back I have the changing title commit and
now I see that yeah.
Andre just changed the background generator which is in red too.
Cool generator.
So as you can see we have a history of all the changes and we can always go back if there's any mistakes
but there's one issue right now.
If I go back to the code and I go to Marcy's computer I see that well she still has a background generator
here.
Why is that.
Well because her computer doesn't know that.
Get hub has been updated.
The next command I'm going to show you this is the last one I'm going to show you in this video is get
pull.
So remember get push to push the changes to get Hongkong and get pull to pull Whatever's the latest.
So I do get pull.
And there you go.
You see over here that it shows me that index that Asian mail file was was changed.
Now you see that my title has been changed to cool generator.
Let's just say that Marcy saw my first change and she really really likes how I've added cool generator.
But I think she wants to make it capitalized again.
She's going to save that.
She's going to say get status.
All right.
I have my index that a simple file get and then get commit.
And off the message cap a two lies title and then get push.
There you go again.
I go back I refresh and now there's four commits.
And we see that capitalized title is the new changes the first day of work is done.
I come into the next day of work and while I want to start with whatever the latest project is of back
on generator let's say Marcy worked all night to change that title to cool capitalized I want to make
sure that I have the most updated version.
So what I do is when I get into work in the morning I'll say well I want to make sure that if there's
any changes that Marcy made I know about then so I'm going to say get pull and notice here how the titles
going to change after I do the pull and now I click to Sublime Text.
And there you go.
Cool generator.
All right.
And the next video we're going to expand on this and show you what happens if both Marcy and Andre make
the same changes.
What does get hub do.
I'll see on that one by.