|
| 1 | +git-history(1) |
| 2 | +============== |
| 3 | + |
| 4 | +NAME |
| 5 | +---- |
| 6 | +git-history - EXPERIMENTAL: Rewrite history |
| 7 | + |
| 8 | +SYNOPSIS |
| 9 | +-------- |
| 10 | +[synopsis] |
| 11 | +git history reword <commit> [--ref-action=(branches|head|print)] |
| 12 | + |
| 13 | +DESCRIPTION |
| 14 | +----------- |
| 15 | + |
| 16 | +Rewrite history by rearranging or modifying specific commits in the |
| 17 | +history. |
| 18 | + |
| 19 | +THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE. |
| 20 | + |
| 21 | +This command is related to linkgit:git-rebase[1] in that both commands can be |
| 22 | +used to rewrite history. There are a couple of major differences though: |
| 23 | + |
| 24 | +* linkgit:git-history[1] can work in a bare repository as it does not need to |
| 25 | + touch either the index or the worktree. |
| 26 | +* linkgit:git-history[1] does not execute any linkgit:githooks[5] at the |
| 27 | + current point in time. This may change in the future. |
| 28 | +* linkgit:git-history[1] by default updates all branches that are descendants |
| 29 | + of the original commit to point to the rewritten commit. |
| 30 | +
|
| 31 | +Overall, linkgit:git-history[1] aims to provide a more opinionated way to modify |
| 32 | +your commit history that is simpler to use compared to linkgit:git-rebase[1] in |
| 33 | +general. |
| 34 | + |
| 35 | +Use linkgit:git-rebase[1] if you want to reapply a range of commits onto a |
| 36 | +different base, or interactive rebases if you want to edit a range of commits |
| 37 | +at once. |
| 38 | + |
| 39 | +LIMITATIONS |
| 40 | +----------- |
| 41 | + |
| 42 | +This command does not (yet) work with histories that contain merges. You |
| 43 | +should use linkgit:git-rebase[1] with the `--rebase-merges` flag instead. |
| 44 | + |
| 45 | +Furthermore, the command does not support operations that can result in merge |
| 46 | +conflicts. This limitation is by design as history rewrites are not intended to |
| 47 | +be stateful operations. The limitation can be lifted once (if) Git learns about |
| 48 | +first-class conflicts. |
| 49 | + |
| 50 | +COMMANDS |
| 51 | +-------- |
| 52 | + |
| 53 | +The following commands are available to rewrite history in different ways: |
| 54 | + |
| 55 | +`reword <commit>`:: |
| 56 | + Rewrite the commit message of the specified commit. All the other |
| 57 | + details of this commit remain unchanged. This command will spawn an |
| 58 | + editor with the current message of that commit. |
| 59 | + |
| 60 | +OPTIONS |
| 61 | +------- |
| 62 | + |
| 63 | +`--ref-action=(branches|head|print)`:: |
| 64 | + Control which references will be updated by the command, if any. With |
| 65 | + `branches`, all local branches that point to commits which are |
| 66 | + descendants of the original commit will be rewritten. With `head`, only |
| 67 | + the current `HEAD` reference will be rewritten. With `print`, all |
| 68 | + updates as they would be performed with `branches` are printed in a |
| 69 | + format that can be consumed by linkgit:git-update-ref[1]. |
| 70 | + |
| 71 | +GIT |
| 72 | +--- |
| 73 | +Part of the linkgit:git[1] suite |
0 commit comments