[MUSIC]
>> Good morning. Good afternoon. Good evening.
No matter where you're coming from,
hope you all are doing well.
We're going to learn the basics of Git and
GitHub from an actual beginner standpoint.
I feel like there's a lot of stuff out
there when it comes to Git and GitHub.
If it's your first time, dabbling in it,
it can be really overwhelming,
it cause a lot of stress.
But we're going to show how Git can be
a tool that you can use every single day.
My name is Leon.
I am the Managing Director of Engineering
for a nonprofit called Resilient Coders.
It's my job to help folks get jobs as Software Engineers
and help them get the skills that they
need to become Software Engineers.
I want you to learn how to learn.
We're going to start off this stream not with Git,
not with the terminal not with the GitHub
but with learning how to learn.
It's something that's changed my life,
that's changed the lives of a lot of my students.
If you only listen to two things I say tonight,
one, make sure you have a GitHub account and then two,
make sure you learn how to learn.
Then we're going to break down what
the heck is this terminal thing.
We are going to learn the basics of Git and then we're going to
show how to use GitHub along
with Git to do some really cool stuff.
Before we jump into Git,
we have to start with something called the Terminal.
Whenever you hear the Word terminal,
I don't want it to because fear or panic.
When you hear the Word terminal, I want you to think
of is a place where you can
type commands that because actions.
But there's a place where we can type stuff and
things happen. That's it.
Way back in the day,
if you bought an Apple II and what it gave you was
access to a command line or a CLI, a command-line interface.
You turned on this Apple II computer and instead of getting
a GUI or a Graphical User Interface,
you got a Command Line Interface
and there was no Internet to figure stuff out,
no GUI, no folders, no anything.
From the command line interface,
you could run command,
you could run utilities and you could still
do some pretty cool stuff.
It was just a very different experience.
This command-line interface or eventually we'll
call it the terminals where we access this command-line interface,
it's still alive well today.
We can look at a terminal that I have on
my machine right here in
the bottom right-hand corner. This is my terminal.
I'm going to walk you through some common commands and then I'm
going to show you how to get this working on your own machine.
If you're in Windows, I recommend Git Bash for this evening.
If you're on MacOS or GNU/Linux,
you probably have a program called Terminal.
You could open up and that you could follow along with us.
Let's talk about some common commands.
Right now you can see that I'm in my Class24 folder.
There is a really common command that you can use called pwd.
I'm just going to type "pwd" and this
stands for Print Working Directory.
The cool thing is it can show you the full path to
the folder that I am currently in.
Once I'm in a folder,
I can even do things like make folders wherever I am at.
Keep your eye up here in my GUI and I'm going to type "Mkdir
example" as I have made
a new directory or a new folder called Example.
Some other commands that you're going to see a lot are
Cd or change directory.
If I want to go into the Example folder that I just created,
I could do Cd space and then
example and I could type it all the way
out or I can even just hit "Tab".
I'm right now inside of the Example.
If I want to go Up a level back to Class24,
I could do Cd.. and now I am back in the Class24 folder.
Cd ~ specifically,
what it's going to do is bring me
all the way back to the beginning,
all the way back to my home folder.
Then if I wanted to get back to where I
was into that Class24 folder,
I'm going to have to Cd into it.
So I could Cd Desktop
and then desktop and then I'd be on the Desktop.
I want to create an HTML file inside of that Example folder.
So change directory into my example folder, Cd.
So here I'm going to touch index.html and as soon as I hit
"Enter", you can see that this HTML file was created.
I didn't have to open up VS code,
I didn't have to create a new file,
I didn't have to save,
I could just do Touch index.html and boom,
we have an HTML file.
I'm going to try my best to explain why Git is really useful?
Why as Software Engineers were going to use it all the time?
Git get solves some very important problems for us and Git solves
this problem not for your Word docs
or your essays but for your code.
Git gives you the ability.
It gives you the ability to make save points and
all Version Control System is like
a really fancy term for tracking changes.
It enables you to take what we call Snapshots.
These snapshots you make by making a commit.
Commit is just a fancy term for creating a save point.
Git, one of the most beautiful things
is that once you make a snapshot,
you can roll back to a previous snapshot.
Let's say you are writing
your code and you get lost in the source and you're like,
this is horrendous,
I should have never ever done this.
Instead of having to do command Z,
we could just roll back to one of our snapshots.
There are many ways to install Git.
If you're on windows, I recommend Git for Windows for it
today and then if you're a macOS,
I really love Homebrew.
So what you would do is you would take this link here and
you would grab it and you would paste
it into your terminal over here.
Once you do have it installed there's two commands,
you always want to run these commands before you do anything else.
These will set your global username
for git and your global e-mail for git.
Whatever e-mail you use,
It should be the e-mail that you use for
GitHub just to make your life easier.
Already, let's talk about some basic Git commands.
Then as you get more into Git,
you'll learn a little bit more and a little bit more of the flag.
With Git Init, we can create a special folder that we
can store all of our snapshots in.
We are initializing a Git repository.
So I'm going to do Git init and you
can see I created an empty Git repository,
a place where I can store those snapshots.
Once we have this repository where we can store our snapshots,
we're going to want to gather
all the files that are going to make up the snapshot.
Git add enables us to grab all the stuff.
Eventually, we can use a special command to take
the snapshot that saves all that stuff into the repository.
I could add an individual file.
So I could do something like Git add index.html.
If I just want to add everything to my staging area,
I could just do Git add. .
It's on the stage.
It's in this staging area.
When I am ready,
I can take a snapshot of everything that's on
the stage and put it in that special folder.
The special word that we use to take
the snapshot of everything that's in staging is called Commit.
I can do Git status and Git status shows
me all the stuff that is waiting to be saved,
that's waiting to be part of that snapshot.
What I'm going to do is I'm going to do Git commit.
So now when I hit "Enter", you can see all of my history has now
been saved as a snapshot and
that's now in my repository until I get rid of it.
There's one other thing that I want to
do and that's eventually when you get to branches.
What if you want to try something without borking all your code?
Git actually gives us
this really wonderful feature
that we don't have to rely on just rolling back,
we can actually create branches from our main code.
I'm going to go in and clear
here and I'm going to do a Git status.
So we can see that I'm on main.
What I can do is I can create a new branch where I make
all my risky stuff happen and
then I have to check out that branch.
If I do a Git status,
you can see that I am on Branch risky.
I want to go ahead and make some changes.
I want to create a Risky file.
I, however, don't like the path that I've gone down.
I wanted to go back to my original set of code.
If I do a Git checkout main,
what just happened? Did you see it?
We switched to main and Risky is no longer there.
You can now write code risk free.
I want to show you
one really cool thing and that cool thing is GitHub.
We have all these save points.
GitHub enables us to take our snapshots and put them in the Cloud.
But we also get a whole suite of tools
that make it easier to work with developers.
If you don't have a GitHub account,
make one after class so that way
you can push up the code that we did today.
Thank you, Microsoft Azure,
for sponsoring this class,
for helping us unlock the power of getting GitHub,
for helping us entry-level Engineers
get free places to host our code.
That's the whole key in caboodle.