doc/git-commit: add documentation for fixup=[amend|reword] options

Mentored-by: Christian Couder <chriscool@tuxfamily.org> Mentored-by: Phillip Wood <phillip.wood@dunelm.org.uk> Helped-by: Eric Sunshine <sunshine@sunshineco.com> Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Charvi Mendiratta <charvi077@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Charvi Mendiratta committed Mar 15, 2021 at 13:24 UTC 00ea64ed7a0ee5ef0901b1eeb5add6954925590f
2 files changed +50 -16
Documentation/git-commit.txt
+39 -6
@@ -9,7 +9,7 @@ SYNOPSIS
9 --------
10 [verse]
11 'git commit' [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [--amend]
12 - [--dry-run] [(-c | -C | --fixup | --squash) <commit>]
12 + [--dry-run] [(-c | -C | --squash) <commit> | --fixup [(amend|reword):]<commit>)]
13 [-F <file> | -m <msg>] [--reset-author] [--allow-empty]
14 [--allow-empty-message] [--no-verify] [-e] [--author=<author>]
15 [--date=<date>] [--cleanup=<mode>] [--[no-]status]
@@ -86,11 +86,44 @@ OPTIONS
86 Like '-C', but with `-c` the editor is invoked, so that
87 the user can further edit the commit message.
88
89 ---fixup=<commit>::
90 - Construct a commit message for use with `rebase --autosquash`.
91 - The commit message will be the subject line from the specified
92 - commit with a prefix of "fixup! ". See linkgit:git-rebase[1]
93 - for details.
89 +--fixup=[(amend|reword):]<commit>::
90 + Create a new commit which "fixes up" `<commit>` when applied with
91 + `git rebase --autosquash`. Plain `--fixup=<commit>` creates a
92 + "fixup!" commit which changes the content of `<commit>` but leaves
93 + its log message untouched. `--fixup=amend:<commit>` is similar but
94 + creates an "amend!" commit which also replaces the log message of
95 + `<commit>` with the log message of the "amend!" commit.
96 + `--fixup=reword:<commit>` creates an "amend!" commit which
97 + replaces the log message of `<commit>` with its own log message
98 + but makes no changes to the content of `<commit>`.
99 ++
100 +The commit created by plain `--fixup=<commit>` has a subject
101 +composed of "fixup!" followed by the subject line from <commit>,
102 +and is recognized specially by `git rebase --autosquash`. The `-m`
103 +option may be used to supplement the log message of the created
104 +commit, but the additional commentary will be thrown away once the
105 +"fixup!" commit is squashed into `<commit>` by
106 +`git rebase --autosquash`.
107 ++
108 +The commit created by `--fixup=amend:<commit>` is similar but its
109 +subject is instead prefixed with "amend!". The log message of
110 +<commit> is copied into the log message of the "amend!" commit and
111 +opened in an editor so it can be refined. When `git rebase
112 +--autosquash` squashes the "amend!" commit into `<commit>`, the
113 +log message of `<commit>` is replaced by the refined log message
114 +from the "amend!" commit. It is an error for the "amend!" commit's
115 +log message to be empty unless `--allow-empty-message` is
116 +specified.
117 ++
118 +`--fixup=reword:<commit>` is shorthand for `--fixup=amend:<commit>
119 +--only`. It creates an "amend!" commit with only a log message
120 +(ignoring any changes staged in the index). When squashed by `git
121 +rebase --autosquash`, it replaces the log message of `<commit>`
122 +without making any other changes.
123 ++
124 +Neither "fixup!" nor "amend!" commits change authorship of
125 +`<commit>` when applied by `git rebase --autosquash`.
126 +See linkgit:git-rebase[1] for details.
127
128 --squash=<commit>::
129 Construct a commit message for use with `rebase --autosquash`.
Documentation/git-rebase.txt
+11 -10
@@ -593,16 +593,17 @@ See also INCOMPATIBLE OPTIONS below.
593
594 --autosquash::
595 --no-autosquash::
596 - When the commit log message begins with "squash! ..." (or
597 - "fixup! ..."), and there is already a commit in the todo list that
598 - matches the same `...`, automatically modify the todo list of rebase
599 - -i so that the commit marked for squashing comes right after the
600 - commit to be modified, and change the action of the moved commit
601 - from `pick` to `squash` (or `fixup`). A commit matches the `...` if
602 - the commit subject matches, or if the `...` refers to the commit's
603 - hash. As a fall-back, partial matches of the commit subject work,
604 - too. The recommended way to create fixup/squash commits is by using
605 - the `--fixup`/`--squash` options of linkgit:git-commit[1].
596 + When the commit log message begins with "squash! ..." or "fixup! ..."
597 + or "amend! ...", and there is already a commit in the todo list that
598 + matches the same `...`, automatically modify the todo list of
599 + `rebase -i`, so that the commit marked for squashing comes right after
600 + the commit to be modified, and change the action of the moved commit
601 + from `pick` to `squash` or `fixup` or `fixup -C` respectively. A commit
602 + matches the `...` if the commit subject matches, or if the `...` refers
603 + to the commit's hash. As a fall-back, partial matches of the commit
604 + subject work, too. The recommended way to create fixup/amend/squash
605 + commits is by using the `--fixup`, `--fixup=amend:` or `--fixup=reword:`
606 + and `--squash` options respectively of linkgit:git-commit[1].
607 +
608 If the `--autosquash` option is enabled by default using the
609 configuration variable `rebase.autoSquash`, this option can be