Applying a GitHub pull request in your fork?

Applying a GitHub pull request in your fork?

Are you using a GitHub tool/library/plugin with a pull-request that makes your life easier, but its author

Are you using a GitHub tool/library/plugin with a pull-request that makes your life easier, but its author has not merged it yet? Do you need it urgently but you do not have time to contact its author? Git’s flexibility allows us to apply commits from one place to another easily! See how to do it in 4 simple steps!

1. Fork

Firstly, we fork the repository we are interested in to our GitHub account. Let us see the following repository as an example. We choose the option fork to fork it to our account:

Applying a GitHub pull request in your fork?

2. Clone

We make the clone of our forked repository:

Applying a GitHub pull request in your fork?

git clone https://github.com/hexacta/cordova-plugin-background-mode.git

3. Merge

Here it gets interesting. We make a pull of the original repository, and we specify the pull request whose ID appears in the url of GitHub. For example, if we want the following pull request:

Applying a GitHub pull request in your fork?

When we choose it, we see that the url is https://github.com/katzer/cordova-plugin-background-mode/pull/112
That ID after the pull/ is the ID of the pull request we want. Then, the pull would be:

git pull https://github.com/katzer/cordova-plugin-background-mode refs/pull/112/head

Depending on the change, it may be necessary to make a merge of some conflict.

4. Push

We make a push and we have the pull-request merged in our repository:

git push origin master

Then we can make reference to it; for example, if it were a Node.js plugin we could add it  to our packages.json:

{
  "name": "",
  "version": "0.0.1",
  "devDependencies": {
    "cordova-plugin-background-mode": "https://github.com/hexacta/cordova-plugin-background-mode.git"
  }
}