blob: 547fecf52029a42ffa060befdc0ce792101f8b58 [file] [log] [blame]
Austin Schuh3de0f952021-11-05 14:13:14 -07001#!/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
10set -e
11set -o pipefail
12
13COMMIT=$1
14
15MESSAGE=$(git show -s --format=%B ${COMMIT})
16
17git cherry-pick -m1 ${COMMIT}
18git reset --soft HEAD~
19echo ${COMMIT}^2 > .git/MERGE_HEAD
20git commit --message="${MESSAGE}"