Skip to content

Instantly share code, notes, and snippets.

@jamesarosen
Created October 10, 2014 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jamesarosen/2a1ccf689df93f2f9d8b to your computer and use it in GitHub Desktop.
Save jamesarosen/2a1ccf689df93f2f9d8b to your computer and use it in GitHub Desktop.
GitHub's Merge Button™ from the command line

I love GitHub's Merge Button™... except that it creates a commit with my personal email address even on my work projects. (Or, conversely, that is uses my work email on my personal projects.)

My solution is to create a git-merge-button and add it to my path:

#!/bin/bash

if [ $# -ne 2 ]; then
  echo "Usage: git merge-and-clean-up [branch-name] [pull number]"
  exit 1
fi

git co $1 &&\
  git pr &&\
  git co master &&\
  git pr &&\
  git merge --no-ff $1 -m "Merge branch '$1'"$'\n'$'\n'"Closes #$2" &&\
  git push &&\
  git branch -d $1 &&\
  git push origin ":$1"

When I open pull request 124 for branch "my-branch" and by some miracle it gets a +1, then I just run

$ git merge-button my-branch 124

and I get a merge commit with the right email address that closes the pull request and deletes the relevant branches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment