Skip to content

Instantly share code, notes, and snippets.

@emneo-dev
Last active August 26, 2025 12:01
Show Gist options
  • Save emneo-dev/7987cde5e6faa1ae900dc4a16d8f96f3 to your computer and use it in GitHub Desktop.
Save emneo-dev/7987cde5e6faa1ae900dc4a16d8f96f3 to your computer and use it in GitHub Desktop.
Merge GitHub PR locally with signed merge commit
#!/usr/bin/env sh
# You need the GitHub cli for this script (gh)
# Launch it from the branch you want to be merged in
# Example:
# $ git status
# On branch master
# ...
# $ merge_pr name_of_the_branch_to_merge
if [ -z "$1" ]; then
echo "No argument supplied"
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1
fi
set -e
base_message=$(gh pr view $1 --json author,body,number,title \
-q '. | "Merge #\(.number) \"\(.title)\" from \(.author.name)\n\n\(.body)"')
git merge --no-ff --signoff -m "$base_message" -e $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment