Skip to content

Commit 00ea64e

Browse files
charvi-077gitster
authored andcommitted
doc/git-commit: add documentation for fixup=[amend|reword] options
Mentored-by: Christian Couder <[email protected]> Mentored-by: Phillip Wood <[email protected]> Helped-by: Eric Sunshine <[email protected]> Helped-by: Junio C Hamano <[email protected]> Signed-off-by: Eric Sunshine <[email protected]> Signed-off-by: Charvi Mendiratta <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8bedae4 commit 00ea64e

File tree

2 files changed

+50
-16
lines changed

2 files changed

+50
-16
lines changed

Documentation/git-commit.txt

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SYNOPSIS
99
--------
1010
[verse]
1111
'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>)]
1313
[-F <file> | -m <msg>] [--reset-author] [--allow-empty]
1414
[--allow-empty-message] [--no-verify] [-e] [--author=<author>]
1515
[--date=<date>] [--cleanup=<mode>] [--[no-]status]
@@ -86,11 +86,44 @@ OPTIONS
8686
Like '-C', but with `-c` the editor is invoked, so that
8787
the user can further edit the commit message.
8888

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.
94127

95128
--squash=<commit>::
96129
Construct a commit message for use with `rebase --autosquash`.

Documentation/git-rebase.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -593,16 +593,17 @@ See also INCOMPATIBLE OPTIONS below.
593593

594594
--autosquash::
595595
--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].
606607
+
607608
If the `--autosquash` option is enabled by default using the
608609
configuration variable `rebase.autoSquash`, this option can be

0 commit comments

Comments
 (0)