Last active
March 24, 2020 18:35
-
-
Save therightstuff/1983aaf8bf0c7feec8542df15cac5548 to your computer and use it in GitHub Desktop.
add a parent commit to an existing git commit
This file contains 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
#!/bin/bash | |
# add a parent commit to the specified commit, ideal | |
# for establishing the other parent of a squashed merge | |
# lifted from https://stackoverflow.com/a/41243690/2860309 | |
# usage: ./add_parent.sh TARGET_COMMIT_ID NEW_PARENT_COMMIT_ID | |
set -ex | |
target_commit=$1 | |
additional_parent=$2 | |
git replace --graft $target_commit \ | |
$(git show --pretty=%P $target_commit | head -n1) \ | |
$additional_parent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment