|
| 1 | +git-history(1) |
| 2 | +============== |
| 3 | + |
| 4 | +NAME |
| 5 | +---- |
| 6 | +git-history - EXPERIMENTAL: Rewrite history of the current branch |
| 7 | + |
| 8 | +SYNOPSIS |
| 9 | +-------- |
| 10 | +[synopsis] |
| 11 | +git history reword <commit> |
| 12 | +git history split <commit> [--] [<pathspec>...] |
| 13 | + |
| 14 | +DESCRIPTION |
| 15 | +----------- |
| 16 | + |
| 17 | +Rewrite history by rearranging or modifying specific commits in the |
| 18 | +history. |
| 19 | + |
| 20 | +THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE. |
| 21 | + |
| 22 | +This command is similar to linkgit:git-rebase[1] and uses the same |
| 23 | +underlying machinery. You should use rebases if you want to reapply a range of |
| 24 | +commits onto a different base, or interactive rebases if you want to edit a |
| 25 | +range of commits. |
| 26 | + |
| 27 | +Note that this command does not (yet) work with histories that contain |
| 28 | +merges. You should use linkgit:git-rebase[1] with the `--rebase-merges` |
| 29 | +flag instead. |
| 30 | + |
| 31 | +COMMANDS |
| 32 | +-------- |
| 33 | + |
| 34 | +Several commands are available to rewrite history in different ways: |
| 35 | + |
| 36 | +`reword <commit>`:: |
| 37 | + Rewrite the commit message of the specified commit. All the other |
| 38 | + details of this commit remain unchanged. This command will spawn an |
| 39 | + editor with the current message of that commit. |
| 40 | + |
| 41 | +`split <commit> [--] [<pathspec>...]`:: |
| 42 | + Interactively split up <commit> into two commits by choosing |
| 43 | + hunks introduced by it that will be moved into the new split-out |
| 44 | + commit. These hunks will then be written into a new commit that |
| 45 | + becomes the parent of the previous commit. The original commit |
| 46 | + stays intact, except that its parent will be the newly split-out |
| 47 | + commit. |
| 48 | ++ |
| 49 | +The commit message of the new commit will be asked for by launching the |
| 50 | +configured editor. Authorship of the commit will be the same as for the |
| 51 | +original commit. |
| 52 | ++ |
| 53 | +If passed, _<pathspec>_ can be used to limit which changes shall be split out |
| 54 | +of the original commit. Files not matching any of the pathspecs will remain |
| 55 | +part of the original commit. For more details, see the 'pathspec' entry in |
| 56 | +linkgit:gitglossary[7]. |
| 57 | ++ |
| 58 | +It is invalid to select either all or no hunks, as that would lead to |
| 59 | +one of the commits becoming empty. |
| 60 | + |
| 61 | +CONFIGURATION |
| 62 | +------------- |
| 63 | + |
| 64 | +include::includes/cmd-config-section-all.adoc[] |
| 65 | + |
| 66 | +include::config/sequencer.adoc[] |
| 67 | + |
| 68 | +EXAMPLES |
| 69 | +-------- |
| 70 | + |
| 71 | +Split a commit |
| 72 | +~~~~~~~~~~~~~~ |
| 73 | + |
| 74 | +---------- |
| 75 | +$ git log --stat --oneline |
| 76 | +3f81232 (HEAD -> main) original |
| 77 | + bar | 1 + |
| 78 | + foo | 1 + |
| 79 | + 2 files changed, 2 insertions(+) |
| 80 | +
|
| 81 | +$ git history split HEAD |
| 82 | +diff --git a/bar b/bar |
| 83 | +new file mode 100644 |
| 84 | +index 0000000..5716ca5 |
| 85 | +--- /dev/null |
| 86 | ++++ b/bar |
| 87 | +@@ -0,0 +1 @@ |
| 88 | ++bar |
| 89 | +(1/1) Stage addition [y,n,q,a,d,e,p,?]? y |
| 90 | +
|
| 91 | +diff --git a/foo b/foo |
| 92 | +new file mode 100644 |
| 93 | +index 0000000..257cc56 |
| 94 | +--- /dev/null |
| 95 | ++++ b/foo |
| 96 | +@@ -0,0 +1 @@ |
| 97 | ++foo |
| 98 | +(1/1) Stage addition [y,n,q,a,d,e,p,?]? n |
| 99 | +
|
| 100 | +$ git log --stat --oneline |
| 101 | +7cebe64 (HEAD -> main) original |
| 102 | + foo | 1 + |
| 103 | + 1 file changed, 1 insertion(+) |
| 104 | +d1582f3 split-out commit |
| 105 | + bar | 1 + |
| 106 | + 1 file changed, 1 insertion(+) |
| 107 | +---------- |
| 108 | + |
| 109 | +GIT |
| 110 | +--- |
| 111 | +Part of the linkgit:git[1] suite |
0 commit comments