Skip to content

Instantly share code, notes, and snippets.

@claudioc
Created October 22, 2014 15:09
Show Gist options
  • Save claudioc/e5c5786e0816fcf206eb to your computer and use it in GitHub Desktop.
Save claudioc/e5c5786e0816fcf206eb to your computer and use it in GitHub Desktop.
Easy github pull requests (with hub)
#!/bin/bash
# Get the branch
B=$(git rev-parse --abbrev-ref HEAD)
# Get the remote
R=$(git config branch.${B}.remote)
# Get the last commit message
M=$(git log -n1 --format=format:%s)
# Set the default title
DEF_TITLE="${M} - ${B}"
# Ask the issue number and to change the message
read -e -p "Provide the issue number: " ISSUEN
read -e -p "Provide a meaningful title [${DEF_TITLE}]: " TITLE
TITLE="${TITLE:-${DEF_TITLE}}"
# Display the final command (and copy it to the clipboard
echo
echo hub pull-request -m \"${ISSUEN} ${TITLE}\" -h ${R}:${B}
echo hub pull-request -m \"${ISSUEN} ${TITLE}\" -h ${R}:${B} | pbcopy
echo Copied in your clipboard.
echo
@claudioc
Copy link
Author

No pbcopy for windows. "clip" might do the job.

@claudioc
Copy link
Author

Note that git config branch.${B}.remote will only work if you have first push -u (set the upstream of the branch)

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