@@ -9,7 +9,7 @@ git-replay - EXPERIMENTAL: Replay commits on a new base, works with bare repos t
99SYNOPSIS
1010--------
1111[verse]
12- (EXPERIMENTAL!) 'git replay' ([-- contained] -- onto <newbase > | -- advance <branch >) [-- ref-action[=<mode >]] <revision-range >
12+ (EXPERIMENTAL!) 'git replay' ([-- contained] -- onto <newbase > | -- advance <branch > | -- revert < branch > ) [-- ref-action[=<mode >]] <revision-range >
1313
1414DESCRIPTION
1515-----------
@@ -42,6 +42,25 @@ The history is replayed on top of the <branch> and <branch> is updated to
4242point at the tip of the resulting history. This is different from `--onto` ,
4343which uses the target only as a starting point without updating it.
4444
45+ -- revert <branch >::
46+ Starting point at which to create the reverted commits; must be a
47+ branch name.
48+ +
49+ When `--revert` is specified, the commits in the revision range are reverted
50+ (their changes are undone) and the reverted commits are created on top of
51+ <branch >. The <branch > is then updated to point at the new commits. This is
52+ the same as running `git revert <revision-range>` but does not update the
53+ working tree.
54+ +
55+ The commit messages follow `git revert` conventions: they are prefixed with
56+ "Revert" and include "This reverts commit <hash >." When reverting a commit
57+ whose message starts with "Revert", the new message uses "Reapply" instead.
58+ Unlike cherry-pick which preserves the original author, revert commits use
59+ the current user as the author, matching the behavior of `git revert` .
60+ +
61+ This option is mutually exclusive with `--onto` and `--advance` . It is also
62+ incompatible with `--contained` (which is a modifier for `--onto` only).
63+
4564-- contained::
4665 Update all branches that point at commits in
4766 <revision-range >. Requires `--onto` .
@@ -60,10 +79,11 @@ The default mode can be configured via the `replay.refAction` configuration vari
6079
6180<revision-range >::
6281 Range of commits to replay; see "Specifying Ranges" in
63- linkgit:git-rev-parse[1]. In `--advance <branch>` mode, the
64- range should have a single tip, so that it's clear to which tip the
65- advanced <branch > should point. Any commits in the range whose
66- changes are already present in the branch the commits are being
82+ linkgit:git-rev-parse[1]. In `--advance <branch>` or
83+ `--revert <branch>` mode, the range should have a single tip,
84+ so that it's clear to which tip the advanced or reverted
85+ <branch > should point. Any commits in the range whose changes
86+ are already present in the branch the commits are being
6787 replayed onto will be dropped.
6888
6989:git-replay: 1
@@ -84,9 +104,10 @@ When using `--ref-action=print`, the output is usable as input to
84104 update refs/heads/branch3 ${NEW_branch3_HASH} ${OLD_branch3_HASH}
85105
86106where the number of refs updated depends on the arguments passed and
87- the shape of the history being replayed. When using `--advance`, the
88- number of refs updated is always one, but for `--onto`, it can be one
89- or more (rebasing multiple branches simultaneously is supported).
107+ the shape of the history being replayed. When using `--advance` or
108+ `--revert`, the number of refs updated is always one, but for `--onto`,
109+ it can be one or more (rebasing multiple branches simultaneously is
110+ supported).
90111
91112There is no stderr output on conflicts; see the <<exit-status,EXIT
92113STATUS>> section below.
@@ -152,6 +173,21 @@ all commits they have since `base`, playing them on top of
152173`origin/main`. These three branches may have commits on top of `base`
153174that they have in common, but that does not need to be the case.
154175
176+ To revert commits on a branch:
177+
178+ ------------
179+ $ git replay --revert main topic~2..topic
180+ ------------
181+
182+ This reverts the last two commits from `topic`, creating revert commits on
183+ top of `main`, and updates `main` to point at the result. This is useful when
184+ commits from `topic` were previously merged or cherry-picked into `main` and
185+ need to be undone.
186+
187+ NOTE: For reverting an entire merge request as a single commit (rather than
188+ commit-by-commit), consider using `git merge-tree --merge-base $TIP HEAD $BASE`
189+ which can avoid unnecessary merge conflicts.
190+
155191GIT
156192---
157193Part of the linkgit:git[1] suite
0 commit comments