- Okay, before I'm going to actually show you
how to work with Git, I wanna tell you a little bit
about Git client options to start with.
So before you use a Git client on your computer
it makes sense to set global options
that's on the developer side.
So that doesn't have to deal with what is on the website
but it allows you to make an easier experience.
So the global options are written to a file dot gitconfig
and you can use the git config minus l command
to display a list of global options.
The list that you should do is to set your user information
using git config minus minus global user.name
followed by your name
and user.email followed by your email address.
And to set options on a project only basis.
That's also possible you use git config
just without the minus minus global option.
So once you've done that, you can start working with Git.
Working with Git starts on the Git server,
where the upstream repository is created.
Next, a directory on the local workstation is created
and you use Git init to initialize the Git metadata
in the workstation directory.
And next, you should create a README.md,
which is a read me file
and this read me files for your users.
It contains information about the contents
of the Git directory.
And from there, the normal Git command flow can be applied.
So you are going to use git add to add all files
to the staging area.
And once you're done, you're going to use git commit
minus M followed by the commit message
to commit these files to the HEAD.
Once the files are committed, you push the files
from the HEAD to the remote repository using git push.
Now different push methods are available
and before issuing your first push, you can use git config
minus minus global push.default simple
to set the default push method.
There are different push methods, don't worry about them.
Simple, we'll define in most cases.
Now let me demonstrate how to work
with Git for your convenience.
I've listed the steps that I'm going to do
in this demo right here.
In this demo,
I'm using the Git repository name Tuesday
use whatever kind of name you want.
That is up to you.
Let me show you.
Alright, I am going to click on this icon
in the upper left corner
and I'm going to create a new Git repository,
my new Git repo.
So what do we need to specify?
Well the default settings are good enough as they are,
so I'm just going to click create repository.
Now it is convenient to see right here everything
that you should be doing, in case you don't know what to do.
And you don't want to read my slide.
Well, these are basically the steps that you need to do
to initialize to git repository on the other end.
Let's go to the other end and let me do it there.
So here we are on the Linux site
and I am going to start by creating directory,
mkdir, my new git repo.
And before I'm going to do anything with it,
I wanna do a couple of global options.
So git config minus minus global user.email
and I'm going to set that to my email
and user.name "sandervanvugt".
Next, another common option
is about the default branch name.
So let's use global init.default Branch main.
Now what is the thing?
The thing is that the default branch
or default environment needs to have a name.
In the past that name was Masser.
Nowadays Masser is considered deprecated terminology
and you shouldn't use it anymore.
If you agree to that
then you should tell Git to use something else
and that is what you can do
using this global init.defaultBranch main.
So from now on, if in a documentation you read Masser,
you should replace it with main.
Now this is really something I want to warn you about
because a lot of documentation still has a branch
with the name Masser.
Well, if that doesn't correspond to your default branch
you need to be aware
that you need to change that branch name.
We will probably see some examples of that
as we move forward.
Now let me go to this my new git repo, and let me do
an ls minus A to show you that the directory is empty
and now I'm going to use git init and get init is initiating
the git administrative directory.
It's an empty directory in which files
will be created using echo hello greater than README.md.
Now echo hello, that's not very much.
If this is a real serious repository,
you might want to consider
putting in some actual usage information.
For instance, this is software that people can download
and compile and install.
You might want to provide some instructions about that.
Let me also create a file,
just so that we have more than just the hello file
and then git status.
I like to insert a git status,
git status is telling us no commits yet
and there are some untracked fouls.
Now I'm going to use git add and git status again.
And what do we see?
We see that we have changes to be committed.
So when I use git commit minus M
followed by the commit message,
I like initial commit or something like that.
Again, the commit message is not for you
it's for your users.
So be as specific as you can.
And here we can see that the files are committed
and when I use git status, we can see that we are on
the branch main and the tree is clean.
So they are ready for takeoff.
What's next?
Well, let me first pop the slide so that you can see
the next couple of steps on the slide.
So here we have the next couple of steps in the procedure.
Let me show you.
So now I need to to specify get Branch minus M main.
Well, I need to specify we've set it
as a default so I don't even have to specify it
but I want you to be aware of this option.
It's a common option that you are going to need
sooner or later.
And now next, git remote add origin
https://github.com/your username/name of the repo
My new git repo.
And now we are about ready to push.
But before I'm going to push,
I need my personal access token.
And this is the reason why I'm storing it in a file
and I'm copying it so that it is ready because git push
minus U origin main is what I'm going to use to push.
And there it has the the username.
So the username still might get username and the password,
well, that is not the password
that I'm using to log into the console.
That is the git access token.
So there we go.
Git access token is now used
and we can see that the files are synchronized.
Now to wrap it up, we should have a look
at the Git repository on the GitHub website.
So here we have my new git repo
and look at that, README.md and new file.
So mission accomplished and we are good to continue.