- [Cameron] Hey, I'm Cameron McKenzie,
I'm the editor in chief over at theserverside.com.
And you can follow me on Twitter at Cameron MCNZ.
And right now I'm going to talk to you about
how to perform a merge request in GitLab
and show you how to merge a couple of branches together
using the GitLab admin console.
And not just merge those branches together,
but after you've done the merge,
show you how to go to your local workstation
and bring the results of those merge
onto your local machine.
All things start by logging in to the GitLab
administrative console, which I'm doing right here.
And I'm gonna go into the GitLab made easy project
and dig right into the repository
and specifically look at the different branches
that I've got because I've put together
this fun feature branch and this fun feature branch
has got this amazing file in it called feature file.HTML,
but none of the other branches have it.
So if I go down to the develop branch,
you notice that the develop branch only has the three files
plus the read me, I guess that makes four files.
So what I'd like to do is I'd like to merge
this fun feature branch into the develop branch.
Now I'm gonna do this by issuing a merge request,
and you can see the merge requests over here.
Now, typically with a merge request,
you would have perhaps a developer who wrote the code
and created the topic branch, the feature branch,
asking for a maintainer or some administrator
to actually merge their request in.
I haven't created multiple users right now,
I just have root in my environment.
And so I'm gonna do everything with root.
But let's just imagine that
there's a developer and a maintainer
and the developer wants the maintainer,
someone in the maintainer role to do the merge.
Maybe the developer doesn't have the rights
to merge to the develop branch.
So how would they actually go
and get that fun feature branch
merged into the develop branch?
Well, what they would do
is they would go to the merge request,
say, hey, I'd like to do a new merge request.
Well, what do you wanna merge?
Well, there's that GitLab made easy repository
and there's that fun feature branch I've been working on.
It's now feature complete and I'd like to merge it into,
whoa, don't merge it into master.
It's crazy, that is not git flow.
We wanna merge it into the develop branch,
move it into the development branch
and then maybe run some Jenkins, continuous integration,
or even use CICD from GitLab to verify everything.
And so you click this button, compare branches and continue.
And it says, what's the title of this.
And I'm just gonna say.
Feature file complete, little description.
Who are we gonna assign this to?
So normally you would choose somebody
who's in say the maintainer role.
Someone who's got rights to merge things
into the develop branch to be the assignee.
Now, right now, as I said,
I haven't put together a whole bunch of users
'cause I want people to be able
to follow this tutorial
without having to have gone through that process
of creating a bunch of users.
So I was going to assign this to route,
which is actually me.
Whereas as you can imagine,
there's a developer assigning it to somebody else.
Do I wanna label?
Sure, we'll call it.
There we go.
We've now created a label for it.
And as far as merge options go,
I do not want to delete the storage branch when I'm done.
And there's no milestone associated with this either.
Okay, and so that is the process that you go through
in order to create that submission for a merge request.
So I'll click submit and now that's all done.
Now I'm gonna sign out
just to kind of emphasize the process here.
So now somebody who's a maintainer
signs into GitLab one day.
They go to their GitLab made easy repository,
and then they say, hey, look, there's a merge request there.
Okay, let's see what's happening.
Looks like a developer says that the fun feature is complete
and they want it merged into the,
well, what branch do they wanna merge it into?
We have to click on it to find out.
And it looks like they've got a request
to merge the fun feature branch into the development branch.
So we can go here.
It looks like there is no merge conflicts,
looks like everything works good.
I'm not getting any problems.
So I got the green light to merge these together.
And so now as the maintainer, I say, okay, indeed,
I am gonna merge that in.
I'm not gonna delete the source branch,
I'm gonna do the source branch deletion
in a future tutorial, but I'll click merge.
And now all of a sudden that develop branch
is at the same merge point as the fun feature branch.
In fact, if I go over to the repository, look at branches,
I explore the fun feature branch.
Notice I've got four files in there.
If I go to the repository,
take a look at the develop branch now.
One, two, three, four, five files.
Well, four plus three mean.
The develop branch now has the exact same number of files
as the fun feature branch.
So these two have been merged together.
Again, there's the fun feature branch.
One, two, three, four, plus the read me for five files.
But if I ended up going to the master branch,
which is something I'll merge into later,
you notice there's only four files in there,
three development files, plus the read me.
So, we've now got two of these branches in sync,
but it hasn't affected the other branches.
And of course, if you have a developer,
number of people in the team, they'll all wanna sync up.
And so I'm gonna move into my GitLab repository
on my developer machine.
And you can see right now I got one, two, three, four,
five files in there, that's a feature file.
- Branch in my an, so I'll do a git status,
and you can see them on the fun feature branch.
Okay, that makes sense.
But what happens if I
check out the development branch?
Hey, notice I've only got one, two, three, four files here,
but according to GitLab,
I should have one, two, three, four, five files here.
So what do I do over on the client side?
Well, I just do a git pull.
All of a sudden it says, hey, we've gotta update you.
Looks like there's some changes on the server.
So it's gonna pull some changes in that development branch.
If I now do an LS command, one, two, three, four, five,
files are now on the develop branch.
So I've actually now pulled those changes
and the results of that server side merge request
onto my local machine.
And there you go, that's how easy it is
to perform a merge request in GitLab.
Now, if you wanna learn more about GitLab
follow along in this series of GitLab tutorials,
learn more about git, or for that matter
anything that has to do with server side development,
whether it's Java programming, JavaScript,
agile software development, DevOps microservices,
the whole gambit, head over to the server side.com.
And please follow me on Twitter at Cameron MCNZ.