1 =========================================
2 TopGit -- A different patch queue manager
3 =========================================
9 TopGit aims to make handling of large amounts of interdependent topic
10 branches easier. In fact, it is designed especially for the case where
11 you maintain a queue of third-party patches on top of another (perhaps
12 Git-controlled) project and want to easily organize, maintain and submit
13 them -- TopGit achieves that by keeping a separate topic branch for each
14 patch and providing some tools to maintain the branches. See the USAGE_
15 section for command line details.
21 See the file ``INSTALL``.
27 The TopGit git repository can be found at <http://repo.or.cz/topgit/pro>.
33 Why not use something like StGIT or Guilt or ``rebase -i`` for maintaining
34 your patch queue? The advantage of these tools is their simplicity;
35 they work with patch *series* and defer to the reflog facility for
36 version control of patches (reordering of patches is not
37 version-controlled at all). But there are several disadvantages -- for
38 one, these tools (especially StGIT) do not actually fit well with plain
39 Git at all: it is basically impossible to take advantage of the index
40 effectively when using StGIT. But more importantly, these tools
41 horribly fail in the face of a distributed environment.
43 TopGit has been designed around three main tenets:
45 (i) TopGit is as thin a layer on top of Git as possible. You
46 still maintain your index and commit using Git; TopGit will only
47 automate a few indispensable tasks.
49 (ii) TopGit is anxious about *keeping* your history. It will
50 never rewrite your history, and all metadata is also tracked
51 by Git, smoothly and non-obnoxiously. It is good to have a
52 *single* point when the history is cleaned up, and that is at
53 the point of inclusion in the upstream project; locally, you
54 can see how your patch has evolved and easily return to older
57 (iii) TopGit is specifically designed to work in a
58 distributed environment. You can have several instances of
59 TopGit-aware repositories and smoothly keep them all
60 up-to-date and transfer your changes between them.
62 As mentioned above, the main intended use-case for TopGit is tracking
63 third-party patches, where each patch is effectively a single topic
64 branch. In order to flexibly accommodate even complex scenarios when
65 you track many patches where many are independent but some depend on
66 others, TopGit ignores the ancient Quilt heritage of patch series and
67 instead allows the patches to freely form graphs (DAGs just like Git
68 history itself, only "one level higher"). For now, you have to manually
69 specify which patches the current one depends on, but TopGit might help
70 you with that in the future in a darcs-like fashion.
72 A glossary plug: The union (i.e. merge) of patch dependencies is called
73 a *base* of the patch (topic branch).
75 Of course, TopGit is perhaps not the right tool for you:
77 (i) TopGit is not complicated, but StGIT et al. are somewhat
78 simpler, conceptually. If you just want to make a linear
79 purely-local patch queue, deferring to StGIT instead might
82 (ii) When using TopGit, your history can get a little hairy
83 over time, especially with all the merges rippling through.
92 ## Create and evolve a topic branch
93 $ tg create t/gitweb/pathinfo-action
94 tg: Automatically marking dependency on master
95 tg: Creating t/gitweb/pathinfo-action base from master...
101 ## Create another topic branch on top of the former one
102 $ tg create t/gitweb/nifty-links
103 tg: Automatically marking dependency on t/gitweb/pathinfo-action
104 tg: Creating t/gitweb/nifty-links base from t/gitweb/pathinfo-action...
108 ## Create another topic branch on top of master and submit
109 ## the resulting patch upstream
110 $ tg create t/revlist/author-fixed master
111 tg: Creating t/revlist/author-fixed base from master...
115 tg: Sent t/revlist/author-fixed
117 To: git@vger.kernel.org
118 Cc: gitster@pobox.com
119 Subject: [PATCH] Fix broken revlist --author when --fixed-string
121 ## Create another topic branch depending on two others non-trivially
122 $ tg create t/whatever t/revlist/author-fixed t/gitweb/nifty-links
123 tg: Creating t/whatever base from t/revlist/author-fixed...
124 tg: Merging t/whatever base with t/gitweb/nifty-links...
126 tg: Please commit merge resolution and call: tg create
127 tg: It is also safe to abort this operation using `git reset --hard`
128 tg: but please remember you are on the base branch now;
129 tg: you will want to switch to a different branch.
133 tg: Resuming t/whatever setup...
137 ## Update a single topic branch and propagate the changes to
139 $ git checkout t/gitweb/nifty-links
142 $ git checkout t/whatever
144 Topic Branch: t/whatever (1 commit)
145 Subject: [PATCH] Whatever patch
147 Depends: t/revlist/author-fixed t/gitweb/nifty-links
149 t/gitweb/nifty-links (1 commit)
151 tg: Updating base with t/gitweb/nifty-links changes...
153 tg: Please commit merge resolution and call `tg update` again.
154 tg: It is also safe to abort this operation using `git reset --hard`,
155 tg: but please remember you are on the base branch now;
156 tg: you will want to switch to a different branch.
160 tg: Updating t/whatever against new base...
162 tg: Please resolve the merge and commit. No need to do anything else.
163 tg: You can abort this operation using `git reset --hard` now
164 tg: and retry this merge later using `tg update`.
168 ## Update a single topic branch and propagate the changes
169 ## further through the dependency chain
170 $ git checkout t/gitweb/pathinfo-action
173 $ git checkout t/whatever
175 Topic Branch: t/whatever (1/2 commits)
176 Subject: [PATCH] Whatever patch
178 Depends: t/revlist/author-fixed t/gitweb/nifty-links
180 t/gitweb/pathinfo-action (<= t/gitweb/nifty-links) (1 commit)
182 tg: Recursing to t/gitweb/nifty-links...
183 [t/gitweb/nifty-links] tg: Updating base with t/gitweb/pathinfo-action changes...
185 [t/gitweb/nifty-links] tg: Please commit merge resolution and call `tg update` again.
186 [t/gitweb/nifty-links] tg: It is also safe to abort this operation using `git reset --hard`,
187 [t/gitweb/nifty-links] tg: but please remember you are on the base branch now;
188 [t/gitweb/nifty-links] tg: you will want to switch to a different branch.
189 [t/gitweb/nifty-links] tg: You are in a subshell. If you abort the merge,
190 [t/gitweb/nifty-links] tg: use `exit` to abort the recursive update altogether.
191 [t/gitweb/nifty-links] $ ..resolve..
192 [t/gitweb/nifty-links] $ git commit
193 [t/gitweb/nifty-links] $ tg update
194 [t/gitweb/nifty-links] tg: Updating t/gitweb/nifty-links against new base...
196 [t/gitweb/nifty-links] tg: Please resolve the merge and commit.
197 [t/gitweb/nifty-links] tg: You can abort this operation using `git reset --hard`.
198 [t/gitweb/nifty-links] tg: You are in a subshell. After you either commit or abort
199 [t/gitweb/nifty-links] tg: your merge, use `exit` to proceed with the recursive update.
200 [t/gitweb/nifty-links] $ ..resolve..
201 [t/gitweb/nifty-links] $ git commit
202 [t/gitweb/nifty-links] $ exit
203 tg: Updating base with t/gitweb/nifty-links changes...
204 tg: Updating t/whatever against new base...
206 ## Clone a TopGit-controlled repository
209 $ tg remote --populate origin
214 ## Add a TopGit remote to a repository and push to it
215 $ git remote add foo URL
219 ## Update from a non-default TopGit remote
228 When using TopGit there are several common conventions used when working with
229 TopGit branches. None of them are enforced, they are only suggestions.
231 There are three typical uses for a TopGit branch:
233 1. Normal TopGit branches that represent a single patch. These are known
234 as "patch" TopGit branches.
235 2. Empty TopGit branches with no dependencies (an empty ``.topdeps`` file)
236 that represent a base upon which other "normal" TopGit branches depend.
237 These are known as "base" TopGit branches (not to be confused with
238 the refs/top-bases/... refs).
239 3. Empty TopGit branches that serve as a staging area to bring together
240 several other TopGit branches into one place so they can be used/tested
241 all together. These are known as "stage" TopGit branches.
243 An "empty" TopGit branch is one that does not have any changes of its own --
244 it may still have dependencies though ("stage" branches do, "base" branches do
245 not). The ``tg summary`` output shows empty branches with a ``0`` in the
246 listing. Normal "patch" branches that have not been annihilated, "base" and
247 "stage" branches fall into this category. (Annihilated branches are normally
248 omitted from the ``tg summary`` output but can be shown if given explicitly as
249 an argument to the ``tg summary`` command. However, the message line will be
250 incorrect since an annihilated branch has no ``.topmsg`` file of its own.)
252 A "patch" branch name typically starts with ``t/`` whereas "base" and "stage"
253 branch names often do not.
255 A "base" branch is created by using the ``--no-deps`` option of ``tg create``
256 which will automatically suggest a "[BASE]" message prefix rather than
257 "[PATCH]". A "stage" branch is created like a normal patch branch except that
258 the only changes that will ever be made to it are typically to add/remove
259 dependencies. Its subject prefix must be manually changed to "[STAGE]" to
262 Since both "base" and "stage" branches typically only have a use for the
263 "Subject:" ilne from their ``.topmsg`` file, they are quite easily created
264 using the ``--topmsg`` option of ``tg create``.
266 Use of "stage" and "base" branches is completely optional. However, without
267 use of a "stage" branch it will be difficult to test multiple independent
268 patches together all at once. A "base" branch is merely a convenience that
269 provides more explicit control over when common base for a set of patches gets
270 updated as well as providing a branch that shows in ``tg summary`` output and
271 participates in ``tg remote --populate`` setup.
273 When using the ``tg tag`` command to create tags that record the current state
274 of one or more TopGit branches, the tags are often created with a name that
277 One last thing, you have enabled ``git rerere`` haven't you?
283 Beware, there is no "undo" after running a ``tg update``!
285 Well, that's not entirely correct. Since ``tg update`` never discards commits
286 an "undo" operation is technically feasible provided the old values of all the
287 refs that were affected by the ``tg update`` operation can be determined and
288 then they are simply changed back to their previous values.
290 In practice though, it can be extremely tedious and error prone looking through
291 log information to try and determine what the correct previous values were.
292 Although, since TopGit tries to make sure reflogs are enabled for top-bases
293 refs, using Git's ``@{date}`` notation on all the refs dumped out by a
294 ``tg tag --refs foo``, where "foo" is the branch that was updated whose update
295 needs to be undone, may work.
297 Alternatively, ``tg tag --stash`` can be used prior to the update and then
298 ``tg revert`` used after the update to restore the previous state. This
299 assumes, of course, that you remember to run ``tg tag --stash`` first.
301 The ``tg update`` command understands a ``--stash`` option that tells it to
302 automatically run ``tg tag --stash`` before it starts making changes (if
303 everything is up-to-date it won't run the stash command at all). Again, you
304 must remember to add the ``--stash`` option though.
306 However, there is a preference. Setting the config value ``topgit.autostash``
307 to ``true`` will implicitly add the ``--stash`` option to any ``tg update``
308 command unless an explicit ``--no-stash`` option is given.
310 If you are likely to ever want to undo a ``tg update``, setting
311 ``topgit.autostash`` to ``true`` is highly recommended!
313 Note that the tags saved by ``tg tag --stash`` are stored in the
314 ``refs/tgstash`` ref and its reflog. Unfortunately, while Git is happy to
315 maintain the reflog (once it's been enabled which ``tg tag`` guarantees for
316 ``refs/tgstash``), Git is unable to view an annotated/signed tag's reflog!
317 Instead Git dereferences the tag and shows the wrong thing. Use the
318 ``tg tag -g`` command to view the ``refs/tgstash`` reflog instead.
324 No, this is not a section about budget nonsense. ;)
326 TopGit keeps its metadata in ``.topdeps`` and ``.topmsg`` files. In an effort
327 to facilitate cherry-picking and other Git activities on the patch changes
328 themselves while ignoring the TopGit metadata, TopGit attempts to keep all
329 changes to ``.topdeps`` and ``.topmsg`` files limited to commits that do NOT
330 contain changes to any other files.
332 This is a departure from previous TopGit versions that made no such effort.
334 Primarily this affects ``tg create`` and ``tg import`` (which makes use of
335 ``tg create``) as ``tg create`` will commit the initial versions of
336 ``.topdeps`` and ``.topmsg`` for a new TopGit-controlled branch in their own
337 commit instead of mixing them in with changes to other files.
339 The ``pre-commit`` hook will also attempt to separate out any ``.topdeps`` and
340 ``.topmsg`` changes from commits that include changes to other files.
342 It is possible to defeat these checks without much effort (``pre-commit`` hooks
343 can easily be bypassed, ``tg create`` has a ``--no-commit`` option, many Git
344 commands simply do not run the ``pre-commit`` hook, etc.).
346 If you really, really, really, really want to change the default back to the
347 old behavior of previous TopGit versions where no such sequestration took
348 place, then set the ``topgit.sequester`` config variable explicitly to the
349 value ``false``. But this is not recommended.
352 AMENDING AND REBASING AND UPDATE-REF'ING
353 ----------------------------------------
357 It is okay to manually update a top-bases/... ref when a) it has no depedencies
358 (i.e. it was created with the ``tg create`` ``--no-deps`` option) and b) the
359 old top-bases/... ref value can be fast-forwarded to the new top-bases/...
360 value OR the new value contains ALL of the changes in the old value through
361 some other mechanism (perhaps they were cherry-picked or otherwise applied to
362 the new top-bases/... ref). The same rules apply to non-TopGit-controlled
365 Ignoring this rule and proceeding anyway with a non-fast-forward update to a
366 top-bases/... ref will result in changes present in the new value being merged
367 into the branch (at ``tg update`` time) as expected (possibly with conflicts),
368 but any changes that were contained in the old version of the top-bases/... ref
369 which have been dropped (i.e. are NOT contained in the new version of the
370 top-bases/... ref) will continue to be present in the branch! To get rid of
371 the dropped commits, one or more "revert" commits will have to be manually
372 applied to the tip of the new top-bases/... value (which will then be merged
373 into the branch at next ``tg update`` time).
375 The only time it's safe to amend, rebase, filter or otherwise rewrite commits
376 contained in a TopGit controlled branch or non-TopGit branch is when those
377 commits are NOT reachable via any other ref!
379 Furthermore, while it is safe to rewrite merge commits (provided they meet the
380 same conditions) the merge commits themselves and the branches they are merging
381 in must be preserved during the rewrite and that can be rather tricky to get
382 right so it's not recommended.
384 For example, if, while working on a TopGit-controlled branch ``foo``, a bad
385 typo is noticed, it's okay to ammend/rebase to fix that provided neither
386 ``tg update`` nor ``tg create`` has already been used to cause some other ref
387 to be able to reach the commit with the typo.
389 If an amend or rerwite is done anyway even though the commit with the typo is
390 reachable from some other ref, the typo won't really be removed. What will
391 happen instead is that the new version without the typo will ultimately be
392 merged into the other ref(s) (at ``tg update`` time) likely causing a conflict
393 that will have to be manually resolved and the commit with the typo will
394 continue to be reachable from those other refs!
396 Instead just make a new commit to fix the typo. The end result will end up
397 being the same but without the merge conflicts.
399 See also the discussion in the "NO UNDO" section.
405 TopGit needs to check many thing to determine whether a TopGit branch is
406 up-to-date or not. This can involve a LOT of git commands for a complex
407 dependency tree. In order to speed things up, TopGit keeps a cache of results
408 in a ``tg-cache`` subdirectory in the ``.git`` directory.
410 Results are tagged with the original hash values used to get that result so
411 that items which have not been changed return their results quickly and items
412 which have been changed compute their new result and cache it for future use.
414 The ``.git/tg-cache`` directory may be removed at any time and the cache will
415 simply be recreated in an on-demand fashion as needed, at some speed penalty,
416 until it's fully rebuilt.
418 To force the cache to be fully pre-loaded, run the ``tg summary`` command
419 without any arguments. Otherwise, normal day-to-day TopGit operations should
420 keep it more-or-less up-to-date.
422 While each TopGit command is running, it uses a temporary subdirectory also
423 located in the ``.git`` directory. These directories are named
424 ``tg-tmp.XXXXXX`` where the ``XXXXXX`` part will be random letters and digits.
426 These temporary directories should always be removed automatically after each
427 TopGit command finishes running. As long as you are not in a subshell as a
428 result of a TopGit command stopping and waiting for a manual merge resolution,
429 it's safe to remove any of these directories that may have somehow accidentally
430 been left behind as a result of some failure that occurred while running a
431 TopGit command (provided, of course, it's not actually being used by a TopGit
432 command currently running in another terminal window or by another user on the
438 ``tg [-C <dir>] [-r <remote> | -u] [-c <name>=<val>] <subcommand> [<subcommand option/argument>...]``
440 -C <dir> Change directory to <dir> before doing anything
441 -r <remote> Pretend ``topgit.remote`` is set to <remote>
442 -u Pretend ``topgit.remote`` is not set
443 -c <name=val> Pass config option to git, may be repeated
445 The ``tg`` tool has several subcommands:
447 :`tg annihilate`_: Mark a TopGit-controlled branch as defunct
448 :`tg base`_: Show base commit for one or more TopGit branches
449 :`tg checkout`_: Shortcut for git checkout with name matching
450 :`tg create`_: Create a new TopGit-controlled branch
451 :`tg delete`_: Delete a TopGit-controlled branch cleanly
452 :`tg depend`_: Add a new dependency to a TopGit-controlled branch
453 :`tg export`_: Export TopGit branch patches to files or a branch
454 :`tg files`_: Show files changed by a TopGit branch
455 :`tg help`_: Show TopGit help optionally using a browser
456 :`tg import`_: Import commit(s) to separate TopGit branches
457 :`tg info`_: Show status information about a TopGit branch
458 :`tg log`_: Run git log limiting revisions to a TopGit branch
459 :`tg mail`_: Shortcut for git send-email with ``tg patch`` output
460 :`tg next`_: Show branches directly depending on a TopGit branch
461 :`tg patch`_: Generate a patch file for a TopGit branch
462 :`tg prev`_: Show non-annihilated TopGit dependencies for a branch
463 :`tg push`_: Run git push on TopGit branch(es) and depedencies
464 :`tg rebase`_: Auto continue git rebase if rerere resolves conflicts
465 :`tg remote`_: Set up remote for fetching/pushing TopGit branches
466 :`tg revert`_: Revert ref(s) to a state stored in a ``tg tag``
467 :`tg summary`_: Show various information about TopGit branches
468 :`tg tag`_: Create tag that records current TopGit branch state
469 :`tg update`_: Update TopGit branch(es) with respect to dependencies
473 Our sophisticated integrated help facility. Mostly duplicates
478 # to get help for a particular command:
480 # to get help for a particular command in a browser window:
481 $ tg help -w <command>
482 # to get help on TopGit itself
484 # to get help on TopGit itself in a browser
489 Create a new TopGit-controlled topic branch of the given name
490 (required argument) and switch to it. If no dependencies are
491 specified (by extra arguments passed after the first one), the
492 current branch is assumed to be the only dependency.
494 By default ``tg create`` opens an editor on the new ``.topmsg`` file
495 and then commits the new ``.topmsg`` and ``.topdeps`` files
496 automatically with a suitable default commit message.
498 The commit message can be changed with the ``-m`` (or ``--message``) or
499 ``-F`` (or ``--file``) option. The automatic commit can be suppressed
500 by using the ``--no-ccmmit`` option. Running the editor on the new
501 ``.topmsg`` file can be suppressed by using ``-n`` (or ``--no-edit``)
502 (which also suppresses the automatic commit) or by providing an
503 explicit value for the new ``.topmsg`` file using the ``--topmsg`` or
504 ``--topmsg-file`` option. In any case the ``.topmsg`` content will be
505 automatically reformated to have a ``Subject:`` header line if needed.
507 If more than one dependency is listed, the automatic commit will not
508 take place until AFTER all the listed dependencies have been merged
509 into a base commit which will require some manual merge resolutions if
510 conflicts occur during the merge operations.
512 Previous versions of TopGit behaved as though the ``--no-edit`` option
513 was always given on the command line.
515 The default behavior has been changed to promote a separation between
516 commits that modify ``.topmsg`` and/or ``.topdeps`` and commits that
517 modify other files. This facilitates cleaner cherry picking and other
518 patch maintenance activities.
520 You should edit the patch description (contained in the ``.topmsg``
521 file) as appropriate. It will already contain some prefilled bits.
522 You can set the ``topgit.to``, ``topgit.cc`` and ``topgit.bcc``
523 git configuration variables (see ``man git-config``) in order to
524 have ``tg create`` add these headers with the given default values
525 to ``.topmsg`` before invoking the editor.
527 The main task of ``tg create`` is to set up the topic branch base
528 from the dependencies. This may fail due to merge conflicts if more
529 than one dependencie is given. In that case, after you commit the
530 conflict resolution, you should call ``tg create`` again (without any
531 arguments or with the single argument ``--continue``); it will then
532 detect that you are on a topic branch base ref and resume the topic
533 branch creation operation.
535 With the ``--no-deps`` option at most one dependency may be listed
536 which may be any valid committish (instead of just refs/heads/...) and
537 the newly created TopGit-controlled branch will have an empty
538 ``.topdeps`` file. This may be desirable in order to create a TopGit-
539 controlled branch that has no changes of its own and serves merely to
540 mark the common dependency that all other TopGit-controlled branches
541 in some set of TopGit-controlled branches depend on. A plain,
542 non-TopGit-controlled branch can be used for the same purpose, but the
543 advantage of a TopGit-controlled branch with no dependencies is that it
544 will be pushed with ``tg push``, it will show up in the ``tg summary``
545 and ``tg info`` output with the subject from its ``.topmsg`` file
546 thereby documenting what it's for and finally it can be set up with
547 ``tg create -r`` and/or ``tg remote --populate`` to facilitate sharing.
549 For example, ``tg create --no-deps release v2.1`` will create a TopGit-
550 controlled ``release`` branch based off the ``v2.1`` tag that can then
551 be used as a base for creation of other TopGit-controlled branches.
552 Then when the time comes to move the base for an entire set of changes
553 up to ``v2.2`` the command ``git update-ref top-bases/release v2.2^0``
554 can be used followed by ``tg update --all``. Note that it's only safe
555 to update ``top-bases/release`` directly in this manner because a) it
556 has no depedencies since it was created with the ``--no-deps`` option
557 and b) the old ``top-bases/release`` value can be fast-forwarded to the
558 new ``top-bases/release`` value.
560 Using ``--no-deps`` it's also possible to use ``tg create`` on an
561 unborn branch (omit the dependency name or specify ``HEAD``). The
562 unborn branch itself can be made into the new TopGit branch (rather
563 than being born empty and then having the new TopGit branch based off
564 that) by specifying ``HEAD`` as the new branch's name (which is
565 probably what you normally want to do in this case anyway so you can
566 just run ``tg create --no-deps HEAD`` to accomplish that).
568 In an alternative use case, if ``-r <branch>`` is given instead of a
569 dependency list, the topic branch is created based on the given
570 remote branch. With just ``-r`` the remote branch name is assumed
571 to be the same as the local topic branch being created. Since no
572 new commits are created in this mode (only two refs will be updated)
573 the editor will never be run for this use case. Note that no other
574 options may be combined with ``-r``.
576 The ``--quiet`` (or ``-q``) option suppresses most informational
581 Remove a TopGit-controlled topic branch of the given name
582 (required argument). Normally, this command will remove only an
583 empty branch (base == head) without dependendents; use ``-f`` to
584 remove a non-empty branch or a branch that is depended upon by
587 The ``-f`` option is also useful to force removal of a branch's
588 base, if you used ``git branch -D B`` to remove branch B, and then
589 certain TopGit commands complain, because the base of branch B
592 Normally ``tg delete`` will refuse to delete the current branch.
593 However, giving ``-f`` twice (or more) will force it to do so but it
594 will first detach your HEAD.
596 IMPORTANT: Currently, this command will *NOT* remove the branch
597 from the dependency list in other branches. You need to take
598 care of this *manually*. This is even more complicated in
599 combination with ``-f`` -- in that case, you need to manually
600 unmerge the removed branch's changes from the branches depending
603 See also ``tg annihilate``.
605 | TODO: ``-a`` to delete all empty branches, depfix, revert
609 Make a commit on the current TopGit-controlled topic branch
610 that makes it equal to its base, including the presence or
611 absence of .topmsg and .topdeps. Annihilated branches are not
612 displayed by ``tg summary``, so they effectively get out of your
613 way. However, the branch still exists, and ``tg push`` will
614 push it (except if given the ``-a`` option). This way, you can
615 communicate that the branch is no longer wanted.
617 When annihilating a branch that has dependents (i.e. branches
618 that depend on it), those dependents have the dependencies of
619 the branch being annihilated added to them if they do not already
620 have them as dependencies. Essentially the DAG is repaired to
621 skip over the annihilated branch.
623 Normally, this command will remove only an empty branch
624 (base == head, except for changes to the .top* files); use
625 ``-f`` to annihilate a non-empty branch.
629 Change the dependencies of a TopGit-controlled topic branch.
630 This should have several subcommands, but only ``add`` is
633 The ``add`` subcommand takes an argument naming a topic branch to
634 be added, adds it to ``.topdeps``, performs a commit and then
635 updates your topic branch accordingly. If you want to do other
636 things related to the dependency addition, like adjusting
637 ``.topmsg``, use the option ``--no-commit``. Adding the
638 ``--no-update`` (or ``--no-commit``) option will suppress the
639 ``tg update`` normally performed after committing the change.
641 It is safe to run ``tg depend add`` in a dirty worktree, but the
642 normally performed ``tg update`` will be suppressed in that case
643 (even if neither ``--no-update`` nor ``--no-commit`` is given).
645 You have enabled ``git rerere`` haven't you?
647 | TODO: Subcommand for removing dependencies, obviously
651 List files changed by the current or specified topic branch.
654 -i list files based on index instead of branch
655 -w list files based on working tree instead of branch
659 Show summary information about the current or specified topic
662 Numbers in parenthesis after a branch name such as "(11/3 commits)"
663 indicate how many commits on the branch (11) and how many of those
664 are non-merge commits (3).
666 Alternatively, if ``--heads`` is used then which of the independent
667 TopGit branch heads (as output by ``tg summary --tgish-only --heads)``
668 contains the specified commit (which may be any committish -- defaults
669 to ``HEAD`` if not given). Zero or more results will be output.
673 Generate a patch from the current or specified topic branch.
674 This means that the diff between the topic branch base and head
675 (latest commit) is shown, appended to the description found in
676 the ``.topmsg`` file.
678 The patch is simply dumped to stdout. In the future, ``tg patch``
679 will be able to automatically send the patches by mail or save
680 them to files. (TODO)
683 -i base patch generation on index instead of branch
684 -w base patch generation on working tree instead of branch
685 --binary pass --binary to ``git diff-tree`` to enable generation
687 --diff-opt options after the branch name (and an optional ``--``)
688 are passed directly to ``git diff-tree``
690 In order to pass a sole explicit ``-w`` through to ``git diff-tree`` it
691 must be separated from the ``tg`` options by an explicit ``--``.
692 Or it can be spelled as ``--ignore-all-space`` to distinguuish it from
693 ``tg``'s ``-w`` option.
695 If additional non-``tg`` options are passed through to
696 ``git diff-tree`` (other than ``--binary`` which is fully supported)
697 the resulting ``tg patch`` output may not be appliable.
701 Send a patch from the current or specified topic branch as
704 Takes the patch given on the command line and emails it out.
705 Destination addresses such as To, Cc and Bcc are taken from the
708 Since it actually boils down to ``git send-email``, please refer
709 to the documentation for that for details on how to setup email
710 for git. You can pass arbitrary options to this command through
711 the ``-s`` parameter, but you must double-quote everything. The
712 ``-r`` parameter with a msgid can be used to generate in-reply-to
713 and reference headers to an earlier mail.
715 WARNING: be careful when using this command. It easily sends
716 out several mails. You might want to run::
718 git config sendemail.confirm always
720 to let ``git send-email`` ask for confirmation before sending any
724 -i base patch generation on index instead of branch
725 -w base patch generation on working tree instead of branch
727 | TODO: ``tg mail patchfile`` to mail an already exported patch
728 | TODO: mailing patch series
729 | TODO: specifying additional options and addresses on command line
733 Register the given remote as TopGit-controlled. This will create
734 the namespace for the remote branch bases and teach ``git fetch``
735 to operate on them. However, from TopGit 0.8 onwards you need to
736 use ``tg push``, or ``git push --mirror``, for pushing
737 TopGit-controlled branches.
739 ``tg remote`` takes an optional remote name argument, and an
740 optional ``--populate`` switch. Use ``--populate`` for your
741 origin-style remotes: it will seed the local topic branch system
742 based on the remote topic branches. ``--populate`` will also make
743 ``tg remote`` automatically fetch the remote, and ``tg update`` look
744 at branches of this remote for updates by default.
746 Using ``--populate`` with a remote name causes the ``topgit.remote``
747 git configuration variable to be set to the given remote name.
751 Show overview of all TopGit-tracked topic branches and their
752 up-to-date status. With a branch name limit output to that branch.
753 Using ``--deps-only`` or ``--rdeps`` changes the default from all
754 branches to just the current ``HEAD`` branch but using ``--all`` as
755 the branch name will show results for all branches instead of ``HEAD``.
758 marks the current topic branch
761 indicates that it introduces no changes of its own
764 indicates respectively whether it is local-only
768 indicates respectively if it is ahead or out-of-date
769 with respect to its remote mate
772 indicates that it is out-of-date with respect to its
776 indicates that it has missing dependencies [even if
777 they are recursive ones]
780 indicates that it is out-of-date with respect to
783 This can take a longish time to accurately determine all the
784 relevant information about each branch; you can pass ``-t`` (or ``-l``
785 or ``--list``) to get just a terse list of topic branch names quickly.
787 Passing ``--heads`` shows independent topic branch names and when
788 combined with ``--rdeps`` behaves as though ``--rdeps`` were run with
789 the output of ``--heads``.
791 Alternatively, you can pass ``--graphviz`` to get a dot-suitable output
792 for drawing a dependency graph between the topic branches.
794 You can also use the ``--sort`` option to sort the branches using
795 a topological sort. This is especially useful if each
796 TopGit-tracked topic branch depends on a single parent branch,
797 since it will then print the branches in the dependency order.
798 In more complex scenarios, a text graph view would be much more
799 useful, but that has not yet been implemented.
801 The ``--deps`` option outputs dependency information between
802 branches in a machine-readable format. Feed this to ``tsort`` to
803 get the output from --sort.
805 The ``--deps-only`` option outputs a sorted list of the unique branch
806 names given on the command line plus all of their recursive
807 dependencies (subject to ``--exclude`` of course). When
808 ``--deps-only`` is given the default is to just display information for
809 ``HEAD``, but that can be changed by using ``--all`` as the branch
810 name. Each branch name will appear only once in the output no matter
811 how many times it's visited while tracing the dependency graph or how
812 many branch names are given on the command line to process.
814 The ``--rdeps`` option outputs dependency information in an indented
815 text format that clearly shows all the dependencies and their
816 relationships to one another. When ``--rdeps`` is given the default is
817 to just display information for ``HEAD``, but that can be changed by
818 using ``--all`` as the branch name or by adding the ``--heads`` option.
819 Note that ``tg summary --rdeps --heads`` can be particularly helpful in
820 seeing all the TopGit-controlled branches in the repository and their
821 relationships to one another.
823 Adding ``--with-deps`` replaces the given list of branches (which will
824 default to ``HEAD`` if none are given) with the result of running
825 ``tg summary --deps-only --tgish`` on the list of branches. This can
826 be helpful in limiting ``tg summary`` output to only the list of given
827 branches and their dependencies when many TopGit-controlled branches
828 are present in the repository.
830 With ``--exclude branch``, branch can be excluded from the output
831 meaning it will be skipped and its name will be omitted from any
832 dependency output. The ``--exclude`` option may be repeated to omit
833 more than one branch from the output. Limiting the output to a single
834 branch that has been excluded will result in no output at all.
836 The ``--tgish-only`` option behaves as though any non-TopGit-controlled
837 dependencies encountered during processing had been listed after an
838 ``--exclude`` option.
840 Note that the branch name can be specified as ``HEAD`` as a shortcut for
841 the TopGit-controlled branch that ``HEAD`` is a symbolic ref to.
844 -i Use TopGit metadata from the index instead of the branch
845 -w Use TopGit metadata from the working tree instead of the branch
850 Switch to a topic branch. You can use ``git checkout <branch>``
851 to get the same effect, but this command helps you navigate
852 the dependency graph, or allows you to match the topic branch
853 name using a regular expression, so it can be more convenient.
855 There following subcommands are available:
858 Check out a branch that directly
859 depends on your current branch.
862 Check out a branch that this branch
865 ``tg checkout [goto] [--] <pattern>``
866 Check out a topic branch that
867 matches ``<pattern>``. ``<pattern>``
868 is used as a sed pattern to filter
869 all the topic branches. Both ``goto`` and
870 ``--`` may be omitted provided ``<pattern>``
871 is not ``push``, ``pop``, ``-a``, ``--all``,
872 ``goto``, ``..``, ``--``, ``next``, ``child``,
873 ``prev``, ``parent``, ``-h`` or ``--help``.
876 An alias for ``push``.
878 ``tg checkout child``
879 An alias for ``push``.
882 An alias for ``push``.
885 An alias for ``pop``.
887 ``tg checkout parent``
888 An alias for ``pop``.
891 An alias for ``pop``.
893 If any of the above commands can find more than one possible
894 branch to switch to, you will be presented with the matches
895 and asked to select one of them.
897 The ``<pattern>`` of ``tg checkout goto`` is optional. If you don't
898 supply it, all the available topic branches are listed and you
899 can select one of them.
901 Normally, the ``push`` and ``pop`` commands moves one step in
902 the dependency graph of the topic branches. The ``-a`` option
903 causes them (and their aliases) to move as far as possible.
904 That is, ``tg checkout push -a`` moves to a topic branch that
905 depends (directly or indirectly) on the current branch and
906 that no other branch depends on. ``tg checkout pop -a``
907 moves to a regular branch that the current topic branch
908 depends on (directly or indirectly). If there is more than
909 one possibility, you will be prompted for your selection.
913 Export a tidied-up history of the current topic branch and its
914 dependencies, suitable for feeding upstream. Each topic branch
915 corresponds to a single commit or patch in the cleaned up
916 history (corresponding basically exactly to ``tg patch`` output
917 for the topic branch).
919 The command has three possible outputs now -- either a Git branch
920 with the collapsed history, a Git branch with a linearized
921 history, or a quilt series in new directory.
923 In the case where you are producing collapsed history in a new
924 branch, you can use this collapsed structure either for
925 providing a pull source for upstream, or for further
926 linearization e.g. for creation of a quilt series using git log::
928 git log --pretty=email -p --topo-order origin..exported
930 To better understand the function of ``tg export``, consider this
931 dependency structure::
933 origin/master - t/foo/blue - t/foo/red - master
934 `- t/bar/good <,----------'
935 `- t/baz ------------'
937 (where each of the branches may have a hefty history). Then::
939 master$ tg export for-linus
941 will create this commit structure on the branch ``for-linus``::
943 origin/master - t/foo/blue -. merge - t/foo/red -.. merge - master
944 `- t/bar/good <,-------------------'/
945 `- t/baz ---------------------'
947 In this mode, ``tg export`` works on the current topic branch, and
948 can be called either without an option (in that case,
949 ``--collapse`` is assumed), or with the ``--collapse`` option, and
950 with one mandatory argument: the name of the branch where the
951 exported result will be stored.
953 When using the linearize mode::
955 master$ tg export --linearize for-linus
957 you get a linear history respecting the dependencies of your
958 patches in a new branch ``for-linus``. The result should be more
959 or less the same as using quilt mode and then reimporting it
960 into a Git branch. (More or less because the topological order
961 can usually be extended in more than one way into a total order,
962 and the two methods may choose different ones.) The result
963 might be more appropriate for merging upstream, as it contains
966 Note that you might get conflicts during linearization because
967 the patches are reordered to get a linear history. If linearization
968 would produce conflicts then using ``--quilt`` will also likely result
969 in conflicts when the exported quilt series is applied. Since the
970 ``--quilt`` mode simply runs a series of ``tg patch`` commands to
971 generate the patches in the exported quilt series and those patches
972 will end up being applied linearly, the same conflicts that would be
973 produced by the ``--linearize`` option will then occur at that time.
975 To avoid conflicts produced by ``--linearize`` (or by applying the
976 ``--quilt`` output), use the default ``--collapse`` mode and then use
977 ``tg rebase`` (or ``git rebase -m`` directly) on the collapsed branch
978 (with a suitable <upstream>) followed by ``git format-patch`` on the
979 rebased result to produce a conflict-free patch set.
981 You have enabled ``git rerere`` haven't you?
983 When using the quilt mode::
985 master$ tg export --quilt for-linus
987 would create the following directory ``for-linus``::
989 for-linus/t/foo/blue.diff
990 for-linus/t/foo/red.diff
991 for-linus/t/bar/good.diff
999 With ``--quilt``, you can also pass the ``-b`` parameter followed
1000 by a comma-separated explicit list of branches to export, or
1001 the ``--all`` parameter (which can be shortened to ``-a``) to
1002 export them all. The ``--binary`` option enables producing Git
1003 binary patches. These options are currently only supported
1006 In ``--quilt`` mode the patches are named like the originating
1007 topgit branch. So usually they end up in subdirectories of the
1008 output directory. With the ``--flatten`` option the names are
1009 mangled so that they end up directly in the output dir (slashes
1010 are replaced with underscores). With the ``--strip[=N]`` option
1011 the first ``N`` subdirectories (all if no ``N`` is given) get
1012 stripped off. Names are always ``--strip``'d before being
1013 ``--flatten``'d. With the option ``--numbered`` (which implies
1014 ``--flatten``) the patch names get a number as prefix to allow
1015 getting the order without consulting the series file, which
1016 eases sending out the patches.
1018 | TODO: Make stripping of non-essential headers configurable
1019 | TODO: Make stripping of [PATCH] and other prefixes configurable
1020 | TODO: ``--mbox`` option to export instead as an mbox file
1021 | TODO: support ``--all`` option in other modes of operation
1022 | TODO: For quilt exporting, export the linearized history created in
1023 a temporary branch--this would allow producing conflict-less
1028 Import commits within the given revision range into TopGit,
1029 creating one topic branch per commit. The dependencies are set
1030 up to form a linear sequence starting on your current branch --
1031 or a branch specified by the ``-d`` parameter, if present.
1033 The branch names are auto-guessed from the commit messages and
1034 prefixed by ``t/`` by default; use ``-p <prefix>`` to specify an
1035 alternative prefix (even an empty one).
1037 Alternatively, you can use the ``-s NAME`` parameter to specify
1038 the name of the target branch; the command will then take one
1039 more argument describing a *single* commit to import.
1043 Update the current, specified or all topic branches with respect
1044 to changes in the branches they depend on and remote branches.
1045 This is performed in two phases -- first, changes within the
1046 dependencies are merged to the base, then the base is merged
1047 into the topic branch. The output will guide you on what to do
1048 next in case of conflicts.
1050 You have enabled ``git rerere`` haven't you?
1052 When ``-a`` (or ``--all``) is specifed, updates all topic branches
1053 matched by ``<pattern>``'s (see ``git-for-each-ref(1)`` for details),
1054 or all if no ``<pattern>`` is given. Any topic branches with missing
1055 dependencies will be skipped entirely unless ``--skip`` is specified.
1057 When ``--skip`` is specifed, an attempt is made to update topic
1058 branches with missing dependencies by skipping only the dependencies
1059 that are missing. Caveat utilitor.
1061 When ``--stash`` is specified (or the ``topgit.autostash`` config
1062 value is set to ``true``), a ref stash will be automatically created
1063 just before beginning updates if any are needed. The ``--no-stash``
1064 option may be used to disable a ``topgit.autostash=true`` setting.
1065 See the ``tg tag`` ``--stash`` option for details.
1067 After the update, if a single topic branch was specified, it is
1068 left as the current one; if ``-a`` was specified, it returns to
1069 the branch which was current at the beginning.
1071 If your dependencies are not up-to-date, ``tg update`` will first
1072 recurse into them and update them.
1074 If a remote branch update brings in dependencies on branches
1075 that are not yet instantiated locally, you can either bring in
1076 all the new branches from the remote using ``tg remote
1077 --populate``, or only pick out the missing ones using ``tg create
1078 -r`` (``tg summary`` will point out branches with incomplete
1079 dependencies by showing an ``!`` next to them).
1081 | TODO: ``tg update -a -c`` to autoremove (clean) up-to-date branches
1085 If ``-a`` or ``--all`` was specified, pushes all non-annihilated
1086 TopGit-controlled topic branches, to a remote repository.
1087 Otherwise, pushes the specified topic branches -- or the
1088 current branch, if you don't specify which. By default, the
1089 remote gets all the dependencies (both TopGit-controlled and
1090 non-TopGit-controlled) and bases pushed to it too. If
1091 ``--tgish-only`` was specified, only TopGit-controlled
1092 dependencies will be pushed, and if ``--no-deps`` was specified,
1093 no dependencies at all will be pushed.
1095 The ``--dry-run`` and ``--force`` options are passed directly to
1096 ``git push`` if given.
1098 The remote may be specified with the ``-r`` option. If no remote
1099 was specified, the configured default TopGit remote will be
1104 Prints the base commit of each of the named topic branches, or
1105 the current branch if no branches are named. Prints an error
1106 message and exits with exit code 1 if the named branch is not
1111 Prints the git log of the named topgit branch -- or the current
1112 branch, if you don't specify a name.
1114 NOTE: if you have merged changes from a different repository, this
1115 command might not list all interesting commits.
1119 Creates a TopGit annotated/signed tag or lists the reflog of one.
1121 A TopGit annotated tag records the current state of one or more TopGit
1122 branches and their dependencies and may be used to revert to the tagged
1123 state at any point in the future.
1125 When reflogs are enabled (the default in a non-bare repository) and
1126 combined with the ``--force`` option a single tag name may be used as a
1127 sort of TopGit branch state stash. The special branch name ``--all``
1128 may be used to tag the state of all current TopGit branches to
1129 facilitate this function and has the side-effect of suppressing the
1130 out-of-date check allowing out-of-date branches to be included.
1132 As a special feature, ``--stash`` may be used as the tag name in which
1133 case ``--all`` is implied if no branch name is listed (instead of the
1134 normal default of ``HEAD``), ``--force`` and ``--no-edit`` (use
1135 ``--edit`` to change that) are automatically activated and the tag will
1136 be saved to ``refs/tgstash`` instead of ``refs/tags/<tagname>``.
1137 The ``--stash`` tag name may also be used with the ``-g``/``--reflog``
1140 The mostly undocumented option ``--allow-outdated`` will bypass the
1141 out-of-date check and is implied when ``--stash`` or ``--all`` is used.
1143 A TopGit annotated/signed tag is simply a Git annotated/signed tag with
1144 a "TOPGIT REFS" section appended to the end of the tag message (and
1145 preceding the signature for signed tags). PEM-style begin and end
1146 lines surround one line per ref where the format of each line is
1147 full-hash SP ref-name. A line will be included for each branch given
1148 on the command line and each ref they depend on either directly or
1151 If more than one TopGit branch is given on the command line, a new
1152 commit will be created that has an empty tree and all of the given
1153 TopGit branches as parents and that commit will be tagged. If a single
1154 TopGit branch is given, then it will be tagged.
1156 All the options for creating a tag serve the same purpose as their Git
1157 equivalents except for two. The ``--refs`` option suppresses tag
1158 creation entirely and emits the "TOPGIT REFS" section that would have
1159 been included with the tag. If the ``--no-edit`` option is given and
1160 no message is supplied (via the ``-m`` or ``-F`` option) then the
1161 default message created by TopGit will be used without running the
1164 With ``-g`` or ``--reflog`` show the reflog for a tag. Unlike
1165 ``git log -g``, ``tg tag --reflog`` normally shows the message from the
1166 tag (if a tag) or the commit (if a commit) if available rather than
1167 the message from the reflog itself. With ``--reflog-message`` only
1168 show the message (if any) from the reflog. Non-tag entries are
1169 annotated with their type unless ``--no-type`` is given. TopGit tags
1170 are created with a reflog if core.logallrefupdates is enabled (the
1171 default for non-bare repositories). Unfortunately Git is incapable
1172 of showing a tag's reflog (using git log -g) as it will first resolve
1173 the tag before checking to see if it has a reflog. Git can, however,
1174 show reflogs for lightweight tags (using git log -g) just fine but
1175 that's not helpful here. Use the ``-g`` or ``--reflog`` option to see
1176 the reflog for an actual tag object. This also works on non-TopGit
1177 annotated/signed tags as well provided they have a reflog. The number
1178 of entries shown may be limited with the ``-n`` option. If the tagname
1179 is omitted then ``--stash`` is assumed and ``--reflog-message`` will
1180 be implied (use ``--no-reflog-message`` or ``--commit-message`` to
1183 The ``--delete`` option is a convenience option that runs the
1184 ``git update-ref -d`` command on the specified tag removing it and its
1185 reflog (if it has one).
1187 The ``--clear`` option clears all but the most recent (the ``@{0}``)
1188 reflog entries from the reflog for the specified tag. It's equivalent
1189 to dropping all the higher numbered reflog entries.
1191 The ``--drop`` option drops the specified reflog entry and requires the
1192 given tagname to have an ``@{n}`` suffix where ``n`` is the reflog
1193 entry number to be dropped. This is really just a convenience option
1194 that runs the appropriate ``git reflog delete`` command.
1196 Note that when combined with ``tg revert``, a tag created by ``tg tag``
1197 can be used to transfer TopGit branches. Simply create the tag, push
1198 it somewhere and then have the recipient run ``tg revert`` to recreate
1199 the TopGit branches. This may be helpful in situations where it's not
1200 feasible to push all the refs corresponding to the TopGit-controlled
1201 branches and their top-bases.
1205 Provides a ``git rebase`` rerere auto continue function. It may be
1206 used as a drop-in replacement front-end for ``git rebase -m`` that
1207 automatically continues the rebase when ``git rerere`` information is
1208 sufficient to resolve all conflicts.
1210 You have enabled ``git rerere`` haven't you?
1212 If the ``-m`` or ``--merge`` option is not present then ``tg rebase``
1213 will complain and not do anything.
1215 When ``git rerere`` is enabled, previously resolved conflicts are
1216 remembered and can be automatically staged (see ``rerere.autoUpdate``).
1218 However, even with auto staging, ``git rebase`` still stops and
1219 requires an explicit ``git rebase --continue`` to keep going.
1221 In the case where ``git rebase -m`` is being used to flatten history
1222 (such as after a ``tg export --collapse`` prior to a
1223 ``git format-patch``), there's a good chance all conflicts have already
1224 been resolved during normal merge maintenance operations so there's no
1225 reason ``git rebase`` could not automatically continue, but there's no
1226 option to make it do so.
1228 The ``tg rebase`` command provides a ``git rebase --auto-continue``
1231 All the same rebase options can be used (they are simply passed through
1232 to Git unchanged). However, the ``rerere.autoUpdate`` option is
1233 automatically temporarily enabled while running ``git rebase`` and
1234 should ``git rebase`` stop asking one to resolve and continue, but all
1235 conflicts have already been resolved and staged using rerere
1236 information, then ``git rebase --continue`` will be automatically run.
1240 Provides the ability to revert one or more TopGit branches and their
1241 dependencies to a previous state contained within a tag created using
1242 the ``tg tag`` command. In addition to the actual revert mode
1243 operation a list mode operation is also provided to examine a tag's ref
1246 The default mode (``-l`` or ``--list``) shows the state of one or more
1247 of the refs/branches stored in the tag data. When no refs are given on
1248 the command line, all refs in the tag data are shown. With the special
1249 ref name ``--heads`` then the indepedent heads contained in the tag
1250 data are shown. The ``--deps`` option shows the specified refs and all
1251 of their dependencies in a single list with no duplicates. The
1252 ``--rdeps`` option shows a display similar to ``tg summary --rdeps``
1253 for each ref or all independent heads if no ref is given on the command
1256 The revert mode has three submodes, dry-run mode (``-n`` or
1257 ``--dry-run``), force mode (``-f`` or ``--force``) and interactive mode
1258 (``-i`` or ``--interactive``). If ``--dry-run`` (or ``-n``) is given
1259 no ref updates will actually be performed but what would have been
1260 updated is shown instead. If ``--interactive`` (or ``-i``) is given
1261 then the editor is invoked on an instruction sheet allowing manual
1262 selection of the refs to be updated before proceeding. Since revert is
1263 potentially a destructive operation, at least one of the submodes must
1264 be specified explicitly. If no refs are listed on the command line
1265 then all refs in the tag data are reverted. Otherwise the listed refs
1266 and all of their dependencies (unless ``--no-deps`` is given) are
1267 reverted. Unless ``--no-stash`` is given a new stash will be created
1268 using ``tg tag --stash`` (except, of course, in dry-run mode) just
1269 before actually performing the updates to facilitate recovery from
1272 Both modes accept fully-qualified (i.e. starts with ``refs/``) ref
1273 names as well as unqualified names (which will be assumed to be located
1274 under ``refs/heads/``). In revert mode a tgish ref will always have
1275 both its ``refs/heads/`` and ``refs/top-bases/`` values included no
1276 matter how it's listed unless ``--no-deps`` is given and the ref is
1277 fully qualified (i.e. starts with ``refs/``) or one or the other of its
1278 values was removed from the instruction sheet in interactive mode. In
1279 list mode a tgish ref will always have both its ``refs/heads/`` and
1280 ``refs/top-bases/`` values included only when using the ``--deps`` or
1281 ``--rdeps`` options.
1283 The ``--tgish-only`` option excludes non-tgish refs (i.e. refs that do
1284 not have a ``refs/heads/<name>``, ``refs/top-bases/<name>`` pair).
1286 The ``--exclude`` option (which can be repeated) excludes specific
1287 refs. If the name given to ``--exclude`` is not fully-qualified (i.e.
1288 starts with ``refs/``) then it will exclude both members of a tgish ref
1291 The ``--quiet`` (or ``-q``) option may be used in revert mode to
1292 suppress non-dry-run ref change status messages.
1294 The special tag name ``--stash`` (as well as with ``@{n}`` suffixes)
1295 can be used to refer to ``refs/tgstash``.
1297 The ``tg revert`` command supports tags of tags that contains TopGit
1298 refs. So, for example, if you do this::
1301 git tag -f -a -m "tag the tag" newtag newtag
1303 Then ``newtag`` will be a tag of a tag containing a ``TOPGIT REFS``
1304 section. ``tg revert`` knows how to dereference the outermost
1305 tag to get to the next (and the next etc.) tag to find the
1306 ``TOPGIT REFS`` section so after the above sequence, the tag ``newtag``
1307 can still be used successfully with ``tg revert``.
1309 NOTE: If HEAD points to a ref that is updated by a revert operation
1310 then NO WARNING whatsoever will be issued, but the index and working
1311 tree will always be left completely untouched (and the reflog for
1312 the pointed-to ref can always be used to find the previous value).
1316 Outputs the direct dependencies for the current or named branch.
1319 -i show dependencies based on index instead of branch
1320 -w show dependencies based on working tree instead of branch
1324 Outputs all branches which directly depend on the current or
1328 -i show dependencies based on index instead of branch
1329 -w show dependencies based on working tree instead of branch
1337 TopGit stores all the topic branches in the regular ``refs/heads/``
1338 namespace (so we recommend distinguishing them with the ``t/`` prefix).
1339 Apart from that, TopGit also maintains a set of auxiliary refs in
1340 ``refs/top-*``. Currently, only ``refs/top-bases/`` is used, containing the
1341 current *base* of the given topic branch -- this is basically a merge of
1342 all the branches the topic branch depends on; it is updated during ``tg
1343 update`` and then merged to the topic branch, and it is the base of a
1344 patch generated from the topic branch by ``tg patch``.
1346 All the metadata is tracked within the source tree and history of the
1347 topic branch itself, in ``.top*`` files; these files are kept isolated
1348 within the topic branches during TopGit-controlled merges and are of
1349 course omitted during ``tg patch``. The state of these files in base
1350 commits is undefined; look at them only in the topic branches
1351 themselves. Currently, two files are defined:
1354 Contains the description of the topic branch in a
1355 mail-like format, plus the author information, whatever
1356 Cc headers you choose or the post-three-dashes message.
1357 When mailing out your patch, basically only a few extra
1358 mail headers are inserted and then the patch itself is
1359 appended. Thus, as your patches evolve, you can record
1360 nuances like whether the particular patch should have
1361 To-list / Cc-maintainer or vice-versa and similar
1362 nuances, if your project is into that. ``From`` is
1363 prefilled from your current ``GIT_AUTHOR_IDENT``; other
1364 headers can be prefilled from various optional
1365 ``topgit.*`` git config options.
1368 Contains the one-per-line list of branches this branch
1369 depends on, pre-seeded by ``tg create``. A (continuously
1370 updated) merge of these branches will be the *base* of
1373 IMPORTANT: DO NOT EDIT ``.topdeps`` MANUALLY!!! If you do so, you need to
1374 know exactly what you are doing, since this file must stay in sync with
1375 the Git history information, otherwise very bad things will happen.
1377 TopGit also automagically installs a bunch of custom commit-related
1378 hooks that will verify whether you are committing the ``.top*`` files in a
1379 sane state. It will add the hooks to separate files within the ``hooks/``
1380 subdirectory, and merely insert calls to them to the appropriate hooks
1381 and make them executable (but will make sure the original hook's code is
1382 not called if the hook was not executable beforehand).
1384 Another automagically installed piece is a ``.git/info/attributes``
1385 specifier for an ``ours`` merge strategy for the files ``.topmsg`` and
1386 ``.topdeps``, and the (intuitive) ``ours`` merge strategy definition in
1393 There are two remaining issues with accessing topic branches in remote
1396 (i) Referring to remote topic branches from your local repository
1397 (ii) Developing some of the remote topic branches locally
1399 There are two somewhat contradictory design considerations here:
1401 (a) Hacking on multiple independent TopGit remotes in a single
1403 (b) Having a self-contained topic system in local refs space
1405 To us, (a) does not appear to be very convincing, while (b) is quite
1406 desirable for ``git-log topic`` etc. working, and increased conceptual
1409 Thus, we choose to instantiate all the topic branches of given remote
1410 locally; this is performed by ``tg remote --populate``. ``tg update``
1411 will also check if a branch can be updated from its corresponding remote
1412 branch. The logic needs to be somewhat involved if we are to "do the
1413 right thing". First, we update the base, handling the remote branch as
1414 if it was the first dependency; thus, conflict resolutions made in the
1415 remote branch will be carried over to our local base automagically.
1416 Then, the base is merged into the remote branch and the result is merged
1417 to the local branch -- again, to carry over remote conflict resolutions.
1418 In the future, this order might be adjustable on a per-update basis, in
1419 case local changes happen to be diverging more than the remote ones.
1421 All commands by default refer to the remote that ``tg remote --populate``
1422 was called on the last time (stored in the ``topgit.remote`` git
1423 configuration variable). You can manually run any command with a
1424 different base remote by passing ``-r REMOTE`` *before* the subcommand
1431 The following references are useful to understand the development of
1432 topgit and its subcommands.
1435 http://lists-archives.org/git/688698-add-list-and-rm-sub-commands-to-tg-depend.html
1438 THIRD-PARTY SOFTWARE
1439 --------------------
1441 The following software understands TopGit branches:
1443 * `magit <http://magit.github.io/>`_ -- a git mode for emacs
1445 IMPORTANT: Magit requires its topgit mode to be enabled first, as
1446 described in its documentation, in the "Activating extensions"
1447 subsection. If this is not done, it will not push TopGit branches
1448 correctly, so it's important to enable it even if you plan to mostly use
1449 TopGit from the command line.