In the interview that we did at the beginning of the class,
we talked with John about GitHub, where GitHub is a Git hosting website, and
John told you all about it. For this class, we will be
using GitHub as our Git hosting. Let's see how GitHub works in practice and
let's see some of the common features offered by GitHub.
This is what we'll do in the third part of this Git demo. What I'm showing here
is the GitHub website and as I said, GitHub is a Git hosting website and
you can create an account on GitHub by simply signing up on the website. And
because we already have an account that we're simply going to sign in
to see what kind of functionality GitHub offers. And we're going to specify our
username and password. And as you can see on the GitHub website,
you can use this menu up on the right to create a new repository or
change the account settings. Let's click on our user profile. And
here we can see some statistics for our user. For
example, we can see statistic about our contributions and our repositories. So
now if we go to the Repositories view, we can create a new repository.
We give it a name. Let's call it myrepo. We can provide the description for
the repository. If we want, we can initialize the repository by adding a README
file. And even though we are not doing it right now, if you can see up here,
you can also add a license here on the right and it allows you
to choose from a set of predefined licenses. And you can also a .gitignore file,
which, in case you don't know what that is, it's a very convenient file that
will automatically exclude from the repositories file that should not be added.
So if you remember in the lesson we said there are things that you should not
add to the repositories. For example, derived files. So
here, using this menu, you can pick the type of project that you have.
For example, Java project or PHP project or many other kinds of projects. And
the GitHub will automatically add that file for you.
But let's skip that for now and simply create our repository. And
that creates a repository that contains the README file because that's what we
decided to do. And it also allows you to edit the README file by clicking on it.
It will bring up an editor and here you can write, you know,
for example, initial readme for your project. Then you can add your
commit message up there and then you can commit the changes to your README file.
The site also provides many other features, like, for example, creating issues,
pull requests, adding and editing a wiki, and also, you know,
defining other characteristics and settings for the repository. Now, if we go to
the repository, you can see that we also get the HTTPS link for the repository.
So this is the URL that you can use to clone your repository. If you remember,
with a git clone command, that's the URL that you can specify. So
let's try to do that and clone that repository. So we're going to copy this URL.
To do that, we're going to execute git clone and specify the URL that we
just copied. And you can see that the project was created, was cloned locally.
And if we go under myrepo, which is the name of the repository, you can see that
the README file that we created on GitHub is here. So if we create a new file,
which we're going to call again, newFile just to be clear. And then we
can add it, commit it, specifying as usual a commit message. So at this point,
we can push our locked out changes to the remote GitHub repository. And
because the GitHub repository is password protected,
we have to specify our login and password. And of course, if you
pass the wrong password, GitHub is not going to let you in. So let's try again.
Let's try to get the password right this time. I'm going to specify again,
my login and my password. At this point, the push is successful and
my changes are actually pushed to the master, which is the GitHub repository.
To double check that, let's go back to the GitHub repository and as you can see,
that the file that we added, newFile, is there as expected. And of course,
there's many more things that you can do on the GitHub website, so
I strongly encourage you to go and try out things. But
the key message here is that the GitHub is a Git hosting website where you
can get an account and create your remote repositories.