Last active
August 26, 2025 12:01
-
-
Save emneo-dev/7987cde5e6faa1ae900dc4a16d8f96f3 to your computer and use it in GitHub Desktop.
Merge GitHub PR locally with signed merge commit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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