diff options
| author | Junio C Hamano <gitster@pobox.com> | 2025-11-08 10:33:19 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-11-08 10:33:19 -0800 |
| commit | 374eaa29420f6c01755fc579e08032fdb9962a7c (patch) | |
| tree | 1c82d8fdfb7bf79615c95be2277388addcbb2bb7 /Documentation/git-history.adoc | |
| parent | Merge branch 'ms/doc-worktree-side-by-side' into seen (diff) | |
| parent | builtin/history: implement "split" subcommand (diff) | |
| download | git-374eaa29420f6c01755fc579e08032fdb9962a7c.tar.gz git-374eaa29420f6c01755fc579e08032fdb9962a7c.zip | |
Merge branch 'ps/history' into seen
"git history" history rewriting UI.
Comments?
* ps/history:
builtin/history: implement "split" subcommand
cache-tree: allow writing in-memory index as tree
add-patch: add support for in-memory index patching
add-patch: remove dependency on "add-interactive" subsystem
add-patch: split out `struct interactive_options`
add-patch: split out header from "add-interactive.h"
builtin/history: implement "reword" subcommand
builtin: add new "history" command
replay: stop using `the_repository`
replay: extract logic to pick commits
wt-status: provide function to expose status for trees
Diffstat (limited to 'Documentation/git-history.adoc')
| -rw-r--r-- | Documentation/git-history.adoc | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/Documentation/git-history.adoc b/Documentation/git-history.adoc new file mode 100644 index 0000000000..3d6b2665f8 --- /dev/null +++ b/Documentation/git-history.adoc @@ -0,0 +1,111 @@ +git-history(1) +============== + +NAME +---- +git-history - EXPERIMENTAL: Rewrite history of the current branch + +SYNOPSIS +-------- +[synopsis] +git history reword <commit> +git history split <commit> [--] [<pathspec>...] + +DESCRIPTION +----------- + +Rewrite history by rearranging or modifying specific commits in the +history. + +THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE. + +This command is similar to linkgit:git-rebase[1] and uses the same +underlying machinery. You should use rebases if you want to reapply a range of +commits onto a different base, or interactive rebases if you want to edit a +range of commits. + +Note that this command does not (yet) work with histories that contain +merges. You should use linkgit:git-rebase[1] with the `--rebase-merges` +flag instead. + +COMMANDS +-------- + +Several commands are available to rewrite history in different ways: + +`reword <commit>`:: + Rewrite the commit message of the specified commit. All the other + details of this commit remain unchanged. This command will spawn an + editor with the current message of that commit. + +`split <commit> [--] [<pathspec>...]`:: + Interactively split up <commit> into two commits by choosing + hunks introduced by it that will be moved into the new split-out + commit. These hunks will then be written into a new commit that + becomes the parent of the previous commit. The original commit + stays intact, except that its parent will be the newly split-out + commit. ++ +The commit message of the new commit will be asked for by launching the +configured editor. Authorship of the commit will be the same as for the +original commit. ++ +If passed, _<pathspec>_ can be used to limit which changes shall be split out +of the original commit. Files not matching any of the pathspecs will remain +part of the original commit. For more details, see the 'pathspec' entry in +linkgit:gitglossary[7]. ++ +It is invalid to select either all or no hunks, as that would lead to +one of the commits becoming empty. + +CONFIGURATION +------------- + +include::includes/cmd-config-section-all.adoc[] + +include::config/sequencer.adoc[] + +EXAMPLES +-------- + +Split a commit +~~~~~~~~~~~~~~ + +---------- +$ git log --stat --oneline +3f81232 (HEAD -> main) original + bar | 1 + + foo | 1 + + 2 files changed, 2 insertions(+) + +$ git history split HEAD +diff --git a/bar b/bar +new file mode 100644 +index 0000000..5716ca5 +--- /dev/null ++++ b/bar +@@ -0,0 +1 @@ ++bar +(1/1) Stage addition [y,n,q,a,d,e,p,?]? y + +diff --git a/foo b/foo +new file mode 100644 +index 0000000..257cc56 +--- /dev/null ++++ b/foo +@@ -0,0 +1 @@ ++foo +(1/1) Stage addition [y,n,q,a,d,e,p,?]? n + +$ git log --stat --oneline +7cebe64 (HEAD -> main) original + foo | 1 + + 1 file changed, 1 insertion(+) +d1582f3 split-out commit + bar | 1 + + 1 file changed, 1 insertion(+) +---------- + +GIT +--- +Part of the linkgit:git[1] suite |
