Skip to content

Instantly share code, notes, and snippets.

@SerafimArts
Forked from alopresto/Merging PR for 2 branches
Created September 19, 2020 05:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SerafimArts/8731ed00632cdee7f24492b228647b2c to your computer and use it in GitHub Desktop.
Save SerafimArts/8731ed00632cdee7f24492b228647b2c to your computer and use it in GitHub Desktop.
Instructions to merge pull requests for multiple branches (master, support, etc.)
#Steps to merge/close pull requests with two main branches
As NiFi now has a 1.0 (master) and 0.x (support) branch, pull requests (PR) must be applied to both. Here is a step-by-step guide for committers to ensure this occurs for all PRs.
1. Check out the latest master
``` $ git checkout master
$ git pull upstream master
```
2. Check out the PR (example #327). This will be in `detached-HEAD` state. (Note: You may need to edit the `.git/config` file to add the `fetch` lines [below](#fetch))
` $ git checkout upstream/pr/327`
3. Create a branch for the PR
` $ git checkout -b pr327`
4. Apply the changes and sign off. This could be through a `commit --amend`, `rebase`, etc.
``` $ git commit --amend -s
# Edit the commit file to contain "This closes #327. "
$ git log
# Copy commit id of last commit
```
5. Switch back to the master branch
` $ git checkout master`
6. Merge the changes. You can use `cherry-pick`, `merge`, etc.
` $ git cherry-pick <commit id>`
7. (Optional) Ensure the commit was applied successfully
` $ git log`
8. Push to the Apache repository (master branch)
` $ git push apache master`
9. Switch to the support branch
` $ git checkout -t upstream/0.x` (or `$ git checkout 0.x; git pull` if this branch already exists locally)
10. (Optional) Check the status of the branch
` $ git log`
11. Apply the changes from the PR branch
` $ git cherry-pick <commit id>`
12. Push to the Apache repository (support branch)
` $ git push apache 0.x`
<a name="fetch"></a>
##Fetch Config
To ensure you are able to pull the PR directly, add the following lines to your `.git/config` file.
```[remote "upstream"]
url = git@github.com:apache/nifi.git
fetch = +refs/heads/*:refs/remotes/github/*
fetch = +refs/pull/*/head:refs/remotes/github/pr/*
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment