Austin Schuh | 3de0f95 | 2021-11-05 14:13:14 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # The script replays a merge based on its first parent. |
| 4 | # This will create a new merge with the same message and second parent, but with |
| 5 | # its first parent as the current commit. |
| 6 | # |
| 7 | # It is advised for now to backup your repo before running this command and |
| 8 | # make sure the git history is what you want until we use it more. |
| 9 | |
| 10 | set -e |
| 11 | set -o pipefail |
| 12 | |
| 13 | COMMIT=$1 |
| 14 | |
| 15 | MESSAGE=$(git show -s --format=%B ${COMMIT}) |
| 16 | |
| 17 | git cherry-pick -m1 ${COMMIT} |
| 18 | git reset --soft HEAD~ |
| 19 | echo ${COMMIT}^2 > .git/MERGE_HEAD |
| 20 | git commit --message="${MESSAGE}" |