So this is our GitHub or Git project now.
And to be honest,
things are a bit lonely up to this point, right?
Because basically we only used GitHub so far to bring our
locally managed Git project to the cloud.
This has great advantages.
For example,
we have a backup.
So to say,
in case our computer crashes,
and we can also access our code from anywhere with the help
of the personal access token of course.
Nevertheless,
we saw this earlier on the slide when we introduced GitHub.
We also have other advantages that are only available when
using it in combination with GitHub.
And one of the core advantages here
is the collaboration part.
So the option to work on projects together
with other developers,
and this is where we will dive deeper.
Now at this stage of the course,
at this stage of this module,
and to understand this,
we have to go back to this public versus
private repository
thing we saw when we created our remote repository
here on GitHub.
For this,
I'm here in another browser.
This is the safari browser on Mac here.
And if you look at the right top part here of this page,
you see that I am not logged into GitHub here with my
account.
I'm on the M-LOAM GitHub page.
So basically on the GitHub page of the account
I used for the,
well,
first lectures of this module,
GitHub part.
Now,
and as you see this web Def GitHub repository,
we created is a public repository.
You can see it here.
And if I select this now
and go to code over here,
I could clone the code.
We saw this process already.
So with the help of this URL,
we can access the code.
And then we could theoretically push this code to this
remote repository again.
Of course you would need the personal access token granting
us access to the account that holds this repository.
So again,
my accounts here,
which is the so-called owner of this repository,
but theoretically,
this would work.
Mm from a practical perspective though,
this doesn't make too much sense.
Assuming that this is a rather confidential project
so to say an internal project,
we are working on discord for our purposes for example,
be a new update of the academy.com website.
Well, this wouldn't be something
we share in the public repository
here,
we would rather use a private repository and then add a
so-called collaborator to this project,
which would be another GitHub account.
So the account of the person that has a specific task
assigned as part of this website update,
we might want to implement.
What does this mean for us now?
Well,
first this means that we could create a new repository,
a private repository now
for this M-LOAM
so also for your
GitHub account here in this case,
in step one,
as I said,
to do that,
we have multiple options to access the repositories.
One would be to go to our profile over here and then go to
your repositories.
And then we are back on this,
well,
repositories page here,
this ribbon,
this is by the way,
the overview.
So the starting page,
which we can see over here,
if we go back.
So that's again here,
this starting page of the corresponding GitHub account.
So I'm on this page and if it would select it right here
with not being locked in,
I,
of course,
wouldn't be able to create a new repository,
but here in this account,
where I'm logged in.
I could now say I go to the repositories ribbon in here.
I'll create a new repository,
nothing special here.
We saw this already earlier in this module here,
we could give this a name.
Let's maybe call it
shopping
site.
Let's say we have a online shop here.
For example,
we've owned,
create an online shop,
just to give you a better idea of how this might work
practically.
So this is the shopping side repository.
We bond at a description,
but this time we won't make it public,
but we will set it to private so we can choose who can see
and commit to this repository.
And as you see it up here,
we can also choose who can commit for a public repository.
So this collaborator part is of course also possible for
public repositories.
Nevertheless,
typically,
if we have these,
well,
rather confidential projects,
we will use private repositories.
So I also want to show you this repository type here,
we again,
omit the options down here and create this repository now.
Now we could,
again,
connect our local
Git project with this repository.
I'll do this in a few seconds,
but not related to this account here.
Therefore,
what we'll do here is we'll create a new file.
In here,
and call it maybe landing page dot texts
and could say code for
the landing page of the shopping website.
Of course,
these are just some dummy data,
as you can see,
you know,
where I'm coming from.
Okay? So let's scroll down and let's commit this with added
landing page,
for example.
And now we commit this new file,
okay?
With this we are done.
And now let's say we want to have a team page being added to
this website,
and we don't want to do this on our own.
We have another person inside or outside our company.
Doesn't play a role here that has this task assigned.
What this other person needs is just a GitHub account.
And then we can add this person as so-called collaborator.
Where can we add such a collaborator now?
Well,
we want to add a collaborator for a specific repository.
Therefore the profile over here.
So our GitHub profile or our GitHub account and settings is
the wrong area because this affects the entire account
so to say,
but as you're currently inside our repository,
our private repository here,
by the way now.
We can go to the settings option over here
and there we go to manage access,
this option.
In here,
we can now see that we have a private repository.
So only those with access to this repository can view it.
And I can also prove this to you.
If I quickly go back to the,
well,
safari browser here with
the GitHub page being opened.
So in here this page,
and if I reload,
this,
you see,
we still only have this web dev GitHub repository in here
because that's the public one.
So we now have a private repository,
which was exactly our goal.
So let's go back and here we can see that we have zero
collaborators who have access to this repository.
And down here,
we can invite a so-called collaborator.
So why don't we do this to see what this is all about?
So let's click here.
And here we can now search for a
username,
the full name or the email off another GitHub account.
And for this,
I'll use my other GitHub account that I have,
which is called
manulorenz,
please don't use the same one to send me the invitations,
because well this would not be the goal of this lecture,
to be honest.
So I'll select my other account in case you want to follow
along,
you can just create a second GitHub account for yourself to
then try this.
So I'll use my other account.
And now I'll add this account to this repository as
so-called collaborator,
let me do this by clicking on to add to this repository.
Now,
down here,
you see that we are awaiting the response and yet,
we have a pending in white.
And if the other person in this case,
while the other person is also myself,
but let's assume that we have two different persons here.
So if the other person then checks his email account,
then this is what this invitation looks like.
And if the other person then clicks onto view invitation and
important this person has to be logged in into the GitHub
account that was invited,
then this other account should see this page here.
And with that,
we can now accept this invitation.
And this means we added the other account as collaborator to
our project.
And now will be also see that this collaborator has the
right to push changes to our shopping side repository.
And if we now go back to the page who owns this repository.
So in my case,
this M-LOAM user,
so GitHub.com here slash M-LOAM.
So please use your account name here that you're using.
So with this,
you see,
we now are on the overview page again,
and in repositories,
we now can see that besides our
web Def GitHub public repository,
this private repository is also accessible now.
Let's access it here.
And if we go back to our owner account,
so the account who created this repository
and reload this page to
then you see that Manuel Lorenz.
My case here now is a so-called collaborator.
And this collaborator can now of course,
well clone this project,
for example,
add changes,
implement the team page,
for example,
and then push these changes to the remote repository.
How does this work from a practical perspective now?
Well,
for this,
let's go back to the other accounts.
So to the collaborator account.
There,
we can now go to code inside the shopping side repository
and copy the URL.
Now,
I'll create a new empty folder on my computer and the
new visual studio code instance.
So in here I created a new folder collaborate,
which I drag and dropped into a new visual studio code
instance,
as I said,
and we can also,
again,
bring up our um terminal here.
Now in here,
I'll run,
Git clone
now a space and I'll paste the URL.
And as I said to make sure the folders and files are
directly copied into this well collaborate folder,
in my case,
I'll add a space and dot with this.
The copying will be done exactly as I just described it.
Now,
everything was cloned.
No big surprise here,
but now I can,
for example,
add a new file here and call it team
page dot texts.
We won't add any content here.
It's just about the file actually.
And now I can clear this and well,
if I would push this now,
then this would work.
Do you know why?
Well,
because in my case,
I'm working from the same machine here and this machine well
contains the credentials of the owners.
GitHub accounts at this M-LOAM account.
And in the example,
we are well showing you here,
we actually would simulate two different machines.
Therefore here we should get rid of the token of the
personal access token that was stored on this machine.
And we can get rid of this information as follows.
We saw this already in the last lecture,
so we run Git credential
dash
O,
S, X
key chain
space,
erase,
enter.
Now hosts is equal to GitHub.com
and the protocol is
HTTPS.
Let's confirm this with enter twice.
This means we could now push these changes we made before we
do that though,
we have to add these changes of course,
to the staging area.
And then also commit the changes
with a message of added team page.
For example,
like this.
And by the way,
here in our project,
if we check our branch,
you'll see that we are working in the main branch.
In typical projects,
you wouldn't use the same branch to implement a new feature.
You would have used a feature branch for example,
and implemented the change in there,
and then pushed this new branch.
I want to focus on to the collaboration parts
here in general.
Therefore,
we added this change here,
inside this main branch,
nevertheless,
with the change now being well implemented or added as new
commit,
we can now push these change.
And without the collaboration logic we implemented now for
this user,
we would either need the personal access token of the
repository owner account.
So in our case,
this would be this M-LOAM account here,
this one,
or if we wouldn't have this personal access token,
we couldn't push because otherwise
we wouldn't have this required access,
but with the second account.
So this Manuel Lorenz account here now being a collaborator,
granting ourselves access to this account
and the repositories,
this account has access to,
will allow us to push to this repository,
meaning to the shopping site repository we created
in this account here with the other account,
being a collaborator now.
As we are talking about general account access here,
we have to go to our profile settings
down here,
there,
scroll down to the developer settings
to personal access tokens.
And there we can now create a new one
by clicking on to generate new token.
And here we could call it web Def
course.
maybe simple as that and elegant set the scope with all
um rights,
excluding admin rights.
So repo workflow,
right packages,
delete packages,
just notifications,
user delete repo,
and right discussion.
And with this,
we can now generate this token
and copy it from here.
Now, go back to we as code
here now add Git push origin
main.
Let's see.
Now we should be prompted to enter our credentials.
Yes,
this is working.
We don't want to use the Git up extension.
So let's cancel this.
Now we have to enter the username.
Keep in mind.
This now refers to the collaborator accounts username.
So in my case Manulorenz,
here,
I can confirm this with enter.
Now I'll paste the personal access token.
And after confirming this with enter two,
yeah,
we see that our main repository was updated with this added
file now.
And if we go back to the collaborator page for the
repository and there,
if you now click onto the well,
GitHub symbol over there,
we can find this repository here.
You see it as a private repository with this lock symbol
right here.
Let's access this now.
And then you'll see that we added this team page dot text
file as a separate commits to commits in total here.
And by going back to the owner account now,
over here by either doing the same thing
by clicking onto the GitHub symbol or by
accessing the shopping site repo directly in here.
you see,
well, the same thing.
Basically,
we have two commits in here.
Now with the second commit,
including this team page dot text file also visible.
If we click onto the commits there you can see that I added
this,
so this is working,
but what if one of the two people
involved here updates code on GitHub?
How can the other person access this updated code
via Git then?
Because we have to connection to get and get up for both
users for both collaborators.
But this updating process is something
we didn't cover so far.
For this myself here in this owner account.
So to say,
we'll now go back to the repository
and I'll just add a new file in here.
Let's create a new file,
and I'll call this file
added remote dot texts.
So I added this in the remote repository,
I'll omit any texts in there.
And I'll just add this commit
added remote
text file in there.
So this file is added on GitHub now.
So I'll commit this new file and
therefore the repository is updated.
And if,
and I'll go back to vs code
in here,
I am in the collaborator,
of Git project.
So to say,
which you could clear once again,
then we don't have this latest stage in here.
Well to update our local repository,
we can simply run in other Git command and we know Git push
already to bring local changes to the remote repository and
to do it the other way around.
So to bring changes from
the remote repository to our local one,
we just use Git pull.
If we run this command,
now,
you'll see that our local repository was updated.
And by now running Git log,
you'll see that this added remote text file commit is now
part of our local repository.
So this is how this all ties together with this.
We can work locally on Git.
Bring the changes to GitHub also amongst other
collaborators.
And in case our remote repository was updated.
We can receive this updated information locally on Git
with Git pull.
With this,
I want to conclude this collaboration part.
And I would like to introduce one additional core concept,
which is important whenever multiple people might
contribute,
not collaborate,
but contribute to a specific project.
So contribution is the last core part of this lecture.
We'll dive into as a next step.