So, what is this pop-up now?
In case you're using a different editor by the way,
you might not have this pop-up,
but a different one prompting you to enter your user email,
your username, or your password.
The thing is here that although we established a connection
to the remote repository,
we don't have the permission to push to this repository.
So to basically add code or add data
to this remote repository.
And this makes a lot of sense,
because otherwise anybody who would have the URL
of this remote repository could interact with it.
That's of course not how it's supposed to be.
Therefore, to be able to push our code to the repository,
we have to create a so-called personal access token.
Now, where can we find this now and what is that?
Back on GitHub,
we can create this personal access token
here in our profile there under settings.
Before we'll go there though,
the question is why can we create this token right here,
and not individually for a specific repository,
in our case, for this web dev GitHub repository for example.
Because the personal access token
grants anybody who has this token, and that's important,
anybody who has this token can access all repositories
inside your GitHub account,
via git by using this token.
Therefore, you have to be very careful when using this token
and you have to keep this well secretly for yourself.
Otherwise, as I said, other people can access
your GitHub repos via git by using
this personal access token.
However, you can create this token here under settings.
There we'll scroll down a bit to the developer settings,
and there we go to personal access tokens.
This option.
In here, we can now generate a new token,
over here with this button,
and I'll just give it a name, what it's for,
maybe let's say web
dev
course
GitHub
access,
for example.
Below that, you can define an expiration for this token,
so a specific amount of days, or no expiration at all.
And below here you can define which kind
of access rights you grant the user,
so yourself, in this case, who has this access token.
For example, we want to have full control
of private repositories,
at the moment we have a public repository,
but this might change throughout this module.
We want to be able to write and read inside the repositories
of this user account.
We might want to delete things
and here we could define some admin topics,
which we actually don't need.
And I think this is all right.
Maybe some user settings can be ticked, and with that,
we should be ready to go.
Let's not generate the token until you can see
this secret token.
So my secret token, by the way,
at the point of time where you are watching this video,
this token is not valid anymore.
So please don't copy it.
And now we can copy this token by clicking right here,
and go back to VS code.
And there, we won't select allow now
because this would open a dedicated VS code extension.
I want to enter the credentials differently though,
so we will click cancel, and up here now,
we can enter our user name first,
so our GitHub username,
you can find this name again up here in your profile,
so this is the name you have to enter here.
So not my name, your name, of course, in this case.
So let me do that and confirm it with enter.
Now we have to enter the password
and the password now is the personal access token,
so please paste this token now.
And with this, we are hopefully able,
yes, this looks good,
to add this content of our repository to GitHub,
and this looks all right.
We see we created a new branch,
so the main branch on GitHub.
Therefore, if we go back to GitHub now,
and go back to our starting page here,
you see that now we have that newly created repository.
So nothing new, so we can access it here.
So this web dev GitHub repository,
and now this is what the repository page looks like.
Again, you can see the repository name,
and the fact that this is a public repository.
There you can find the code section,
and this section contains all the code
that you have inside this repository.
All the code here, of course, refers
to all the branches and all the commits.
Here we can see that we are in the main branch
and that we only have the main branch in here.
And in this branch, we can now access, of course,
the content in this branch,
so we can access folders and go back if we want to.
And we can also check the different commits inside of this
branch by clicking onto this commits area here.
So let's do that.
And there you see all the commits we added so far
in this branch locally on git.
Now, also available on GitHub.
If we go back to the code section here,
we are back there, and there we also have now
this code button with the URL of this repository
that you can use to establish the connection to it.
So this is how we can create a remote repository,
an empty remote repository,
and how we can then establish a connection
from the local to the remote repository,
and how we can then bring this locally created project
to the remote repository.
What if we now have another scenario where we are working
from a different computer where this project
is not available at all.
And where we would like to access this project now via git?
Well then the process is a bit different,
and as I would like to simulate the situation
from the machine I'm currently working on,
first we should get rid of our current
personal access token that we added.
So to simulate basically a machine which doesn't have access
to this GitHub account here.
For this, I'll go back to VS code and clear this,
and now to get rid of the credentials we just added,
which might also be the case on your computer,
if you want to have access to another GitHub
account that you might own,
that's why I want to show you this resetting process
for the personal access token.
So to do this,
we have to enter, well,
three lines of code here in the command line.
The first is,
git
credential
dash
OSX
key chain
space
erase
this simply refers to the MacOS keychain
which saves these keys internally and safely for you.
So we want to get rid of a specific key restored
in that Apple or MacOS keychain.
So let's confirm this with enter.
Now we have to enter the host of this specific key,
and the host here is equal to github.com.
Let's also confirm this with enter
and the protocol is
HTTPS.
Let's also confirm this with enter,
and now hitting enter twice to make sure it works,
has deleted our personal access token.
So basically our way to interact
with this remote repository,
which means this sets this machine now equal
to a machine which doesn't have access to this project.
Let me clear this now.
Besides this, we still have the project locally
on git here though, and for this,
I'll now close my VS code instance here.
I'll quit Visual Studio code.
And now I'm back on my desktop in this case,
and here,
this git basics folder contains the project
that we just created throughout this module
and I'll now simply delete this, like that.
And with this, this is another machine so to say,
which doesn't contain this project at all,
and which doesn't have any access rights
to this GitHub repository.
Now let me create a new folder first, and call it,
maybe GitHub like this.
And now I'll open a new visual studio code instance,
and drag this folder into it.
And yes, we again, trust the offers and we can close this.
Now let's open our terminal by view, appearance,
and show panel here,
And now the question is,
how can we now bring our remote repos content
to this local repo?
Please note that at the moment, this isn't a repo though,
as I didn't initialize git so far.
I'm aware of that.
But for this, we need another git command
and this is git clone now.
Clone will simply, well clone, the content
of an existing remote repository into our local repository.
To make sure cloning is successful though, we need what?
The URL again, of our repo,
therefore back in GitHub once again.
We go to this code button and copy it right here.
Now let's go back and paste this URL and now stop.
If we would run the command like this now,
this wouldn't be a problem,
but we would create a sub folder inside this GitHub folder,
we would create another folder,
and this is not what I want at this stage.
Therefore, instead of running the command like this,
we'll add a space here and add a dot.
With this, the content of the remote repository
will be copied directly into this GitHub folder.
Let's do this now.
Now the cloning starts, and now it's done
and as you see, we have the GitHub folder,
and in there, the new feature folder,
second commit and so on.
Okay, so this is nice.
So we now have access to this project again,
locally on our machine.
But what if we want to change something now.
Let's say I create a new file and say,
created after clone dot text,
just to make sure we can identify this file easily.
Now I'll add this, as we learned it.
So git add, now git commit dash M,
added
local text
file after clone,
like this.
And now, what if you run again,
git push
origin main.
Does this work?
And by the way, before we continue here,
did you see that adding and committing worked,
although we didn't initialize git,
so we didn't run git in it at all.
And this only work because with git clone,
we copy the entire repository,
including the interrogate logic.
So we copied the full git project, so to say.
However, with git push origin main, let's see what happens.
You see, we have the same thing that we had before,
we were able to clone the repository,
this was possible, but again,
adding content to it, changing the code, adding commits,
is only possible with the corresponding permissions.
So again, we can press cancel here
to follow the same process as before.
Now we have to enter our GitHub username once again,
and now we need to add the personal access token.
If you didn't copy that personal access token before,
you have to create another one.
And as you see in my case, I also didn't do this,
therefore let's create one together.
So we'll again, go to our profile here,
go to settings, go down to developer settings,
personal access tokens.
Well, now you'll see, this is the previous token we had,
I'll just copy the name to be honest,
and I'll delete it now because I cannot access
this token anymore, it's hidden, so let's delete it.
Yes, I understand this.
And now we'll create a new token, paste the name,
and I'll again, give it access to repo, to workflows,
write packages, to delete packages,
no admin rights and user,
and maybe some write access down here.
And with this, we can generate the token again.
Copy it from here.
And paste it up there.
With this in place, let's see.
Yeah, this looks good.
Now we pushed this new commit to our remote repository.
Let's explore this again, but going back
to our landing page, to our repository over here,
and there you can find that we now have
seven commits including this created after the clone
text file that we just added.
So this is how we can interact between git and GitHub.
So far though, we are kind of working alone
in this project, and as I also mentioned,
GitHub is especially good to collaborate
on projects with other developers.
So let's explore the collaboration
options we have in GitHub as a next step.