Skip to content

Instantly share code, notes, and snippets.

@alopresto
Last active May 15, 2024 15:16
Show Gist options
  • Save alopresto/c05485f80799cd3ba02461b07f1e82de to your computer and use it in GitHub Desktop.
Save alopresto/c05485f80799cd3ba02461b07f1e82de 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