Contribute Code via Pull Request at GitHub

Posts about Free/Libre Open Source Software, part 2 Contribute Code via Pull Request at GitHub

Git is the Standard for version control, GitHub Almost Standard in the Git platforms. And Pull Requests, and, in turn, is the standard method to Code to contribute on GitHub is an essential Foundation that should be known to every developer.

Company to the topic

A Pull Request is comprised of many different Commits, it can be helpful to the Changes by Squash together in a single CommitA Pull Request is comprised of many different Commits, it can be helpful to the Changes by Squash together in a single Commit

(Image: Long / GitHub)

GitHub is used in the commercial proprietary environment, especially the Microsoft platform for Open Source projects. Now, there are many ways to various FLOSS projects to contribute to, but are the main contributions to the new Code and Code corrections.

These are usually Pull Requests built in – this is more than a reference, however, lies on the command “git pull”. In GitLab, the equivalent function is called Merge Requestsays the same thing, and also points to more than the “git merge”command.

In the case of Pull Requests, it is a matter of Code to provide a Review process to initiate and to merge finally, actually, the Patches with the Repo. One of the great advantages of Any GitHub user can propose any Changes to the project without having to be otherwise with the operators connected to or in contact – it is a standardized process, with very little Overhead.

In the Following, we make the entire process in Detail, both from the point of view of the contributors as well as the administrator of the Repos. The basic Workflow looks like this: Repo clone, Feature, create a Branch, edit, commit, push, Pull Request, create, Review, process, Merge, and now, once step at a time.

Pull Request to submit

Step 1 is to be held on github.com : fork the Repo to which you want to contribute. In the Following, the intelligibility is to be held for the sake all to a real Repo with real URLs.

Now, switch to the command line and cloning the Repository:

git clone https://github.com/bili123/cli-help.git

Now you should be able to set the local Fork-Repo so that you can update your Master from the Original Master and this merge is necessary, this is:

git remote add upstream https://github.com/bili123/cli-help
git fetch upstream
git checkout master
git merge upstream/master

Then you can start with the actual work – and that starts with a separate Branch for the planned Feature, the proposed correction or other Amendment to, so:

git branch mybranch
git checkout mybranch

It is the Changes in the Repo to follow, without any special features. However, it should be implemented per Branch is really just a theme. The whole procedure ends as usual with a normal “git commit”. Since this Commit is intended for third parties, you should pay particular attention to a good quality, clear Commit message.

Now it is again optional: Before the Commits are pushed in, it serves to bring once again an Update from the Original Master, and any in the meantime, newly added Commits by the Rebase command in the working Branch record – simple to make project managers life easier:

git fetch upstream
git checkout master
git merge upstream/master
git checkout mybranch
git rebase master

In a last step, locally in the Terminal, as is to be expected:

git push –set-upstream origin mybranch

Thus, the Changes are now in the forked Repo on Github, where it then goes even further: by Using the Button “Compare and Pull Request” will take you to the form for Pull Requests. First of all, you can find here the comparison between the original Master Branch and the development branch, so here’s “mybranch”. If everything fits, you can submit the Pull Request.

Alternatively, the Pull Requests as a pure Drafts sending, for example, if this is to be developed Feature is still in an early stage and by Pull Request at all, to clarify, if completion is worth it at all. Essential to the Draft Status is not, however, as the administrator of the Original Repos can set this Status later as well. Pull Requests in Draft Status can not be merged, there is only a small hedge.

Pull Request test and install

Now the perspective is changed: In the Original Repository will now appear, so the submitted Pull Request, which confronted the Manager with four options: Pull Request to accept and merge him in the Draft state, reject them, or simply comment.

In advance, the administrator will want to test but, in General! First of all, the file must for .git/config be adjusted with the following entry below [remote “origin”]:

fetch = +refs/pull/*/head:refs/pull/origin/*

Thus, all of the Pull, you can now Request branches queries:

git fetch origin

As a result, there is a numbered list, for example:

* [new ref]     refs/pull/8/head -> refs/pull/origin/8

Here is the Pull Request in Branch “8”, which can of course also check out lands:

git checkout -b 8 pull/origin/8

In the working directory, the Changes in the Pull Requests are now available and can be tested, however, in Read-only mode.

By default, will not follow after the Test, especially a comment, if it is just small fixes – it is a Review process begins. At GitHub, which is held pleasing simple: The discussion can be directly run on the Pull Request page in the Browser.

More Commits come from Pull-Request-Creator of the “mybranch”Ast are automatically placed in this Pull Request. It can be any adjustments without the need of a new Pull Request create. After all the Details are discussed in the Code and committed have been implemented, you can install the Original administrator of the Pull Request final.

This is most easily done via Github.com – of course also here, with options: As usual, you can work here with the Merge, Rebase or Squash & Merge. Which Option is appropriate, depends on their own internal rules and regulations, but also from the approach of the Pull Request Creator – if this is packing 50 individual Commits in the Pull Request, it should be a previous summarize by Squash in a single Commit quite helpful.

The final Pull Request Merge on GitHub.com.The final Pull Request Merge on GitHub.com.

(Image: Long / GitHub)

Once selected, and, where appropriate, comments, completes a click on the “Confirm Squash & Merge”Button, the process on the Server side. Alternatively to the Browser, you can of course also be in the Terminal merged – on the very regular manner by the Pull of the “mybranch”branch of the forked Repository:

git checkout master
git pull https://github.com/FORKER_NAME/FORKER_REPO mybranch
git merge mybranch
git push origin master

The conclusion offers a full …

git branch -d mybranch

… to delete the already merged into the development branch.

Merge Request

If you are familiar somewhat with Git, it should be clear by now: it is basically in the case of Pull Requests a simple Merges of branches of third parties. At GitHub, it’s called Pull Request after the first action in the Original Repo, the “Get” of the branch in GitLab, it is called Merge Request after the last action in the Original Repo, the Merge of the branch.

Basically, the Pull Request team Workflow is pretty simple, even if the handling is intuitive and, at least in the Terminal here and there a bit tricky, if you look at the Pullen of the Pull Request branches. But of course, this Git Workflow is more complex when many pages are in conflicts or simply accidents happen when Merging or Rebasing.

In this respect, to the end of the hopefully – really very obvious tip: Before you be productive, you should test a second Github account, create, and test, test.

(ID:47077869)

Ready to see us in action:

More To Explore

IWanta.tech
Logo
Enable registration in settings - general
Have any project in mind?

Contact us:

small_c_popup.png