How to Use a Forked Repo with Merge Requests


How to Use a Forked Repo with Merge Requests Today I’m going to walk you through the steps of forking a project and submitting a merge request. I’m also going to show you what it looks like to receive that merge request and how to apply the merge. So, here’s an example of a demo repo. This
is the project that we want to make contributions to, and we can also assume that we do not
have permissions to commit to this project. Now we could actually clone from this repo
and pull it down. The issue is that when we make the changes we commit back up to the
demo repo, we don’t have permission. So, that’s where the forked repo comes into play. With
the forked repo it’s just a clone of the demo repo that we’re going to have permission to.
Now we can clone locally from our forked version, and have the ability to commit and push back
to the fork, and it’s from that fork that we do our merge request. By default, if new
commits are made to the demo repo, they will not be merged into the forked repo automatically.
So, in order to keep our fork updated with the latest commits, we can add the demo repo
as a remote to our local repo. This allows us to pull commits from the demo repo and
merge them locally. From there, we can push back up to our forked repo. Now that we have
a basic idea of how this all works conceptually, let’s go ahead and walk through how we actually
do it. Okay, so I’m here on SourceForge, and I’m
in the demo repository. You can see here that it says “Read access only” and that indicates
that this is not my project or I do not have permissions to Write to this project. So like
we discussed, I want to go ahead and fork this. Over here you see the “Fork” button,
and click on that. We have a few options here. For Project, I can either associate this with
a project I already created, or I can associate it my User account. I’m going to go ahead
and do that. And “Mount Point” just refers to the main URL. So, say “forked-repo” and
hit “Fork.” This status will be updated as soon as it’s finished. I’m going to click
“Refresh.” Okay, now it looks just like the other one did, only we have Read and Write
Access. Let’s go ahead and clone this locally from our forked repo. Go ahead and cd into
that directory. Now we can add a Read Me file, and make sure we add that file to git, commit
it, and then push it back. So, back on SourceForge you can see that this has updated on our fork.
This is a pretty huge improvement, so let’s do a merge request. Click right here on “Merge
Request.” And we have a few options. I generally match the summary to my commit message. The
“Source Branch” refers to our fork branch, which we were on “Master” when we pushed it,
and we’re going to go ahead and Target “Master.” Description is optional, I’m going to leave
that blank. I hit “Save” here. Now you can see that there’s a merge request, and this
is the status. If you click on it we can’t actually merge it, since it’s not our project.
But, let me show you what that looks like on the other end. So, I’ve just logged into
the account that owns this repo. You can see there’s “Read/Write” access to the repo. I’m
going to click here on “Merge Requests,” and now I’m going to click on “Open.” This is
what a merge request looks like from the point of view of the person that owns the project.
The first thing you may notice is this “Merge” button. This “Merge” button is a relatively
new feature at SourceForge, and it basically just checks that there are no conflicts with
this merge. But before I hit the merge button, I want to go ahead and take a look at the
differences. Click on “Commit.” This was a fairly good change, so I’m going to hit the
“Merge” button. Now if you click back on “Master Branch,” you can see that the merge was successful,
and everything is displayed as expected. Licensed under Creative Commons: By Attribution 4.0
Script: “How to Use a Forked Repo with Merge Requests” SourceForge.net (copyright 2015)
Video: “How to Use a Forked Repo with Merge Requests” SourceForge.net (copyright 2015)
Music: “Sunshine” Kevin MacLeod (incompetech.com)

Leave a Reply

Your email address will not be published. Required fields are marked *