latkin
latkin

Reputation: 16812

How to trigger "Merged" status for a pull request with commit message

Like some others, I'm not fond of the default "Merge Pull Request" button behavior, so instead I get things in shape on the local command line, then push back to the repo. I'd like for that push to automatically resolve the original PR as "Merged."

Using the magic strings specified here (found from similar SO question here) is almost what I want. Unfortunately, including closes #123 marks the PR as "Closed", which by itself is kind of synonymous with "Rejected".

I would like to know if there is a way to trigger the same "Merged" status (w/ purple icon) that you get when you just press the button.

So far I've tried adding the following to my commit messages, to no avail:

Upvotes: 14

Views: 2121

Answers (1)

dahlbyk
dahlbyk

Reputation: 77620

GitHub considers a PR "Merged" as soon as the commits in the PR branch are also found in the target branch (typically master). Using a rebase workflow, your process might look like this:

  1. Create a branch tracking your PR branch: git checkout -t origin/my-pr-branch
  2. git rebase master
  3. git push -f origin my-pr-branch (or just git push -f if you've changed push.default to something sane)
  4. Push your changes to remote and local master, closing the PR: git push origin HEAD:master && git push . HEAD:master

Upvotes: 5

Related Questions