6 git-sequencer - Execute a sequence of git instructions
11 'git sequencer' [--batch] [--allow-dirty] [--verbose | --no-advice | --quiet]
13 'git sequencer' --continue | --skip | --abort
14 'git sequencer' --edit | --status
19 Executes a sequence of git instructions to HEAD or `<base>`.
20 The sequence is given by `<file>` or standard input.
21 Also see 'TODO FILE FORMAT' below.
23 Before doing anything, the TODO file is checked for correct syntax
26 In case of a conflict or request in the TODO file, 'git-sequencer' will
27 pause. On conflict you can use 'git-diff' to locate the markers (`<<<<<<<`)
28 and make edits to resolve the conflict.
30 For each file you edit, you need to tell git the changes by doing
34 After resolving the conflict manually and updating the index with the
35 desired resolution, you can continue the sequencing process with
37 git sequencer --continue
39 Alternatively, you can undo the 'git-sequencer' progress with
43 or skip the current instruction with
47 or correct the TODO file with
51 During pauses or when finished with the sequencing task, the current
52 HEAD will always be the result of the last processed instruction.
54 Note that 'git-sequencer' detaches HEAD at the beginning. That means,
55 a commit that has been made by sequencer is not tracked by your initial
56 branch until the sequencing process finishes successfully.
62 Filename of the TODO file. If omitted, standard input is used.
63 See 'TODO FILE FORMAT' below.
66 Run even if working tree is dirty.
70 Run in batch mode. If unexpected user intervention is needed
71 (e.g. a conflict or the need to run an editor),
72 'git-sequencer' aborts.
74 Note that the sanity check fails, if you use this option
75 and an instruction like `edit` or `pause` is in the TODO file.
78 Restart the sequencing process after a pause.
81 Restore the original branch and abort the sequence operation.
84 Restart the sequencing process, skipping the current instruction.
87 Show the current status of 'git-sequencer' and what
88 operations can be done to change that status.
91 Invoke editor to edit the unprocessed part of the TODO file.
93 The file is syntax- and sanity-checked afterwards, so that you can
94 safely run `git sequencer --skip` or `--continue` after editing.
95 If you nonetheless noticed that you made a mistake, you can
96 overwrite `.git/sequencer/todo` with `.git/sequencer/todo.old` and
97 rerun `git sequencer --edit`.
99 If the check fails you are prompted if you want to correct your
100 changes, edit again, cancel editing or really want to save.
103 Suppress advice on intentional and unintentional pauses.
107 Suppress output. Implies `--no-advice`.
117 'git-sequencer' will usually be called by other git commands, like
118 linkgit:git-am[1] or linkgit:git-rebase[1].
124 The TODO file contains one instruction per line.
126 Blank lines will be ignored.
127 All characters after a `#` character are comments and will be ignored until
130 The following instructions can be used:
136 This is useful if you want 'git-sequencer' to do nothing with zero
137 exit status (success).
140 pick [options] <commit>::
141 Pick (see linkgit:git-cherry-pick[1]) a commit.
142 Sequencer will pause on conflicts.
144 See the following list and 'GENERAL OPTIONS' for values of `options`:
148 Revert the changes introduced by pick <commit>.
151 Allow you to pick merge commits by specifying the
152 parent number (beginning from 1) to let sequencer
153 replay the changes relative to the specified parent.
156 patch [options] <file>::
157 If file `<file>` is a pure (diff) patch, then apply the patch.
158 If no `--message` option is given, an editor will
159 be invoked to enter a commit message.
161 If `<file>` is a linkgit:git-format-patch[1]-formatted patch,
162 then the patch will be commited.
164 See the following list and 'GENERAL OPTIONS' for values of `options`:
168 When the patch does not apply cleanly, fall back on
169 3-way merge, if the patch records the identity of blobs
170 it is supposed to apply to, and we have those blobs
174 Pass `-k` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).
177 Pass `-n` flag to 'git-mailinfo' (see linkgit:git-mailinfo[1]).
179 And the following options, that will be passed to 'git-apply':
181 --exclude=<path-pattern>;;
182 Do not apply changes to files matching the given path pattern.
183 This can be useful when importing patchsets, where you want to
184 exclude certain files or directories.
188 Apply the patch in reverse.
191 When applying a patch, ignore additions made by the
192 patch. This can be used to extract the common part between
193 two files by first running 'diff' on them and applying
194 the result with this option, which would apply the
195 deletion part but not addition part.
197 --whitespace=<action>;;
198 Specify behavior on whitespace errors.
199 See linkgit:git-apply[1] for a detailed description.
202 Ensure at least <n> lines of surrounding context match before
203 and after each change. When fewer lines of surrounding
204 context exist they all must match. By default no context is
208 Under certain circumstances, some versions of 'diff' do not
209 correctly detect a missing new-line at the end of the file.
210 As a result, patches created by such 'diff' programs do not
211 record incomplete lines correctly.
212 This option adds support for applying such patches by
213 working around this bug.
216 Remove <n> leading slashes from traditional diff paths.
220 By default, 'git-apply' expects that the patch being
221 applied is a unified diff with at least one line of context.
222 This provides good safety measures, but breaks down when
223 applying a diff generated with --unified=0. To bypass these
224 checks use this option.
227 Do not trust the line counts in the hunk headers, but infer them
228 by inspecting the patch (e.g. after editing the patch without
229 adjusting the hunk headers appropriately).
232 Prepend <root> to all filenames. If a "-p" argument was passed,
233 too, it is applied before prepending the new root.
237 Pause the sequencer process to let you manually make changes.
238 For example, you can re-edit the done commit, split a commit,
239 fix bugs or typos, or make further commits on top of HEAD before
242 After you have finished your changes and added them to the index,
243 invoke `git sequencer --continue`.
244 If you only want to edit the last commit message with an editor,
245 run `git commit --amend` (see linkgit:git-commit[1]) before saying
250 Pick a commit and pause the sequencer process to let you
253 This is a short form for `pick <commit> and `pause` on separate lines.
257 Set a symbolic mark for the last commit.
258 `<mark>` is an unsigned integer starting at 1 and
259 prefixed with a colon, e.g. `:1`.
261 The marks can help if you want to refer to commits that you
262 created during the sequencer process, e.g. if you want to
265 The set marks are removed after the sequencer has completed.
269 Go back (see linkgit:git-reset[1] `--hard`) to commit `<commit-ish>`.
270 `<commit-ish>` can also be given by a mark, if prefixed with a colon.
273 merge [options] <commit-ish1> <commit-ish2> ... <commit-ishN>::
274 Merge commits into HEAD.
276 You can refer to a commit by a mark.
278 If you do not provide a commit message (using `-F`, `-m`, `-C`, `-M`,
279 or `--standard`), an editor will be invoked.
281 See the following list and 'GENERAL OPTIONS' for values of `options`:
284 Append a commit message like 'Merge ... into HEAD'.
285 See also linkgit:git-fmt-merge-msg[1].
288 --strategy=<strategy>;;
289 Use the given merge strategy.
290 See also linkgit:git-merge[1].
294 Set ref `<ref>` to the current HEAD, see also
295 linkgit:git-update-ref[1].
298 squash [options] <commit>::
299 Add the changes introduced by `<commit>` to the last commit.
301 See 'GENERAL OPTIONS' for values of `options`.
303 squash [options] --from <mark>::
304 Squash all commits from the given mark into one commit.
305 There must not be any `merge` instructions between the
306 `mark` instruction and this `squash --from` instruction.
308 See the following list and 'GENERAL OPTIONS' for values of `options`:
311 Sanity check does not fail if you have merges
312 between HEAD and <mark>.
315 run [--directory=<path>] [--] <cmd> <args>...::
316 Run command `<cmd>` with arguments `<args>`.
317 Pause (conflict-like) if exit status is non-zero.
319 If `<path>` is set, sequencer will change directory to `<path>`
320 before running the command and change back after exit.
326 Besides some special options, the instructions
327 `merge`, `patch`, `pick`, `squash` take the following general options:
330 Override the author name and e-mail address used in the commit.
331 Use `A U Thor <author@example.com>` format.
334 --reuse-commit=<commit-ish>::
335 Reuse message and authorship data from specified commit.
338 --reuse-message=<commit-ish>::
339 Reuse message from specified commit.
340 Note that only the commit message is reused
341 and not the authorship information.
345 Take the commit message from the given file.
349 Use the given `<msg>` as the commit message.
352 Add `Signed-off-by:` line to the commit message (if not yet there),
353 using the committer identity of yourself.
357 Regardless what commit message options are given,
358 invoke the editor to allow editing of the commit message.
364 'git-sequencer' returns:
366 * `0`, if 'git-sequencer' successfully completed all the instructions
367 in the TODO file or successfully aborted after
368 `git sequencer --abort`,
369 * `2`, on user-requested pausing, e.g.
370 when using the `edit` instruction.
371 * `3`, on pauses that are not requested, e.g.
372 when there are conflicts to resolve
373 or errors in the TODO file.
374 * any other value on error, e.g.
375 running 'git-sequencer' on a bare repository.
381 'git-sequencer' is writing information into `$GIT_DIR/sequencer/`.
383 The file `$GIT_DIR/sequencer/patch` is generated on conflict so
384 that the user can inspect the original patch.
386 The file `$GIT_DIR/sequencer/todo.old` is generated by
387 `git sequencer --edit` and can be used to overwrite
388 `$GIT_DIR/sequencer/todo` if things are messed up after editing.
390 All other files in this directory should not be touched directly.
396 Here are some examples that shall ease the start with the TODO
399 Manually editing and adding commits
400 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
402 Sequencer allows manual intervention in between.
403 This can be useful to
405 * check if everything has gone right so far,
409 * edit changes and/or commit messages, or
411 * add further manual commits on top of the current one.
413 If you want to do one of this, either change `pick` to `edit`, or
414 add a `pause` line after the specific instruction.
416 Note that if you only want to edit the commit message in an
417 editor, just use the `--edit` option of your `pick` or `patch`
420 `HEAD` refers to the last commit being done by sequencer.
421 So if you want to split a commit, repeat something like
424 $ git reset HEAD^ # Reset index to HEAD^, but keep working tree
425 # HEAD is the last commit being done by sequencer
426 $ git add -p # Add changes interactively to the index, and/or
427 $ git add file1 # Add changes from file1 to the index
428 $ git commit # Commit staged changes
431 until you have no changes to commit, and then run
434 $ git sequencer --continue # Continue sequencer process
441 Squashing commits means putting the changes of many commits into one.
442 If you have two commits `abcdef1` and `fa1afe1` and you want to squash them,
443 feed 'git-sequencer' with a TODO file like:
450 Squash will concatenate the commit messages of `abcdef1` and `fa1afe1` and
451 invoke an editor so that you can edit them.
452 Perhaps you just want to reuse the commit message of `abcdef1` and
453 add a signoff. Then use:
457 squash -C abcdef1 --signoff fa1afe1
460 You can also squash more than two commits.
461 Basically you can do:
468 squash --message "Make indentation consistent" --signoff E
471 If somebody sent you a patch that you have not yet applied and you want
472 to apply it and squash it, or if you have a `pick <commit>` list generated
476 $ git log --pretty=format:'pick %h # %s' --no-merges --reverse A^..E
479 you can use the `mark` and `squash --from` instructions to
480 squash all commits between them into one:
489 squash --message "Make indentation consistent" --signoff --from :0
493 Branching and Merging
494 ~~~~~~~~~~~~~~~~~~~~~
496 Merging branches can easily be done using the `merge` instruction.
497 For an example, it is more interesting to branch, pick some commits
498 and merge. Imagine you want to 'copy' this onto the current branch:
501 ...--A1--A2--A3--A4--A5---MA-A6 refs/heads/old
503 | C1--MC--C2 refs/heads/topic
508 You want the copy to look exactly like this, except that you
509 are not on branch `old`, and you want to call the copy of `topic`
511 Here is a way to achieve this:
515 mark :0 # remember this to pick further commits on trunk A
517 pick B1 # pick commits for trunk B
520 mark :1 # remember this for merge
521 # Why not just merge B3 later?
522 # Then you would merge the original B3 and not the copy.
523 # But in this example you want to merge the copy of B3.
525 reset :0 # go back to the copy of A1
526 pick A2 # go on picking the commits of trunk A
528 mark :2 # remember this to pick further commits on trunk A
530 pick C1 # pick commits for trunk C
531 merge -C MC :1 # merge trunk B
533 ref refs/heads/topic2 # create branch for the C trunk
535 reset :2 # go back to last commit of trunk A (copy of A3)
536 pick A4 # go on picking the commits of trunk A
538 merge --standard topic2 # merge trunk C
543 Proper handling of conflicts
544 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
546 First of all, you are encouraged to use linkgit:git-rerere[1]:
549 $ git config rerere.enabled true # enable rerere
552 Sequencer invokes 'git-rerere' automatically on conflict.
554 If you experience conflicts, try
557 $ git diff # Show conflicting code
558 $ git status # Show conflicting files
561 Then fix these conflicts using your editor and run
564 $ git add file1 file2 file3 # Add modified files to the index
565 $ git status # Make sure working tree is clean
566 $ git sequencer --continue # Continue sequencer process
569 Now assume a conflict happens because you have unproperly edited
572 Imagine your initial TODO file was:
580 But you wanted to pick B before C, and now you have this conflict on
581 picking C. You may first have a look at:
584 $ git sequencer --status
587 This will show you, what has been done, in what step the conflict
588 happened and what is still to do, like this:
591 Already done (or tried):
595 Interrupted by conflict at
601 To abort & restore, invoke:
602 git sequencer --abort
604 git sequencer --continue
605 To skip the current instruction, invoke:
609 A good way to solve that situation is running
612 $ git sequencer --edit
615 and change the file to:
623 Save the file, and invoke:
626 $ git sequencer --skip
629 Then the conflict-ridden `pick C` will be skipped and B is picked,
630 before C will again be picked.
636 Imagine you have test programs within a `tests/` directory in your working
637 tree. But before running your test programs, you have to invoke `make` in
638 the root directory of the working tree to compile your project.
640 If the commit policy of your project says that after every commit the
641 software must be able to compile and the test suite must pass, you
642 are required to check this after every pick.
644 This example shows how 'git-sequencer' can assist you:
649 run --directory=tests ./test-foo
652 run --directory tests -- ./test-bar --expensive-tests
655 run --directory tests make tests
658 Sequencer will be paused, when a run fails (i.e. on non-zero exit status).
659 Then it is your turn to fix the problem and make the tests pass.
661 Note that on `git sequencer --continue`, 'git-sequencer' will not
662 repeat the failed `run` instruction.
670 linkgit:git-cherry-pick[1],
671 linkgit:git-commit[1],
672 linkgit:git-fmt-merge-msg[1],
673 linkgit:git-format-patch[1],
674 linkgit:git-rebase[1],
675 linkgit:git-rerere[1],
676 linkgit:git-reset[1],
677 linkgit:git-update-ref[1]
682 Written by Stephan Beyer <s-beyer@gmx.net>.
687 Documentation by Stephan Beyer and the git-list <git@vger.kernel.org>.
691 Part of the linkgit:git[1] suite