git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: best way to fastforward all tracking branches after a fetch

From
Jeff King <peff@peff.net>
Date
Dec 12, 2011, 08:25 UTC
Message-ID
<20111212082526.GC16511@sigill.intra.peff.net>
In-Reply-To
<1kc5m38.m71ik21ytxkhbM%lists@haller-berlin.de>
On Mon, Dec 12, 2011 at 08:33:15AM +0100, Stefan Haller wrote:
Show 6 quoted lines
> > Local branches can track each other.  So the script needs to toposort
> > the branches, or to loop until either nothing was done or an error
> > happened.  (The latter to prevent an eternal loop on error.)
> 
> Is this just theoretical, or are there real use cases for this? What
> would be a workflow with such a local tracking branch?
I use this all the time.

In git.git, we use a topic branch workflow (i.e., every feature gets its own topic branch, and topics graduate independently to master as they are deemed stable). And we use a patch-submission workflow, which means it's OK for me to rebase my topics locally, because the end-product is a series of patches sent to the list.

Typically I branch off of "origin/master", so the topic is independent of anything else. For example, the "jk/credentials" branch in my git repo is branched from "origin/master" (Junio's master). But sometimes there is a topic that depends on another topic, but should not be part of the same series (because the the first topic can graduate to master, but the second one may still need more time for discussion and cooking). In that case, I'll set the upstream to the other local topic branch. An example of this is the "jk/prompt" series, which depends on "jk/credentials" for infrastructure, but is really a separate issue.

Having the upstream set is convenient, because I can get _just_ the commits in jk/prompt with "git log @{u}..". Or I can rebase _just_ the commits in that topic with "git rebase -i". If my upstream were set to origin, I would accidentally also rebase all of the commits pulled in from jk/credentials, too.

While my topics are still in development (i.e., before they have even hit "next"), I tend to rebase them aggressively (so that I keep them up to date with git development), using a script that is something like[1]:

  for i in `topics`; do
    git rebase $i@{u} $i
  done
And I do topo-sort my topics for exactly the reason mentioned.
-Peff
[1] https://github.com/peff/git/blob/meta/rebase
Previous: Stefan HallerNext: Stefan Haller
Message 16 of 27 in “best way to fastforward all tracking branches after a fetch”
  1. Gelonida NDec 10, 2011
  2. Sitaram ChamartyDec 11, 2011
  3. Gelonida NDec 11, 2011
  4. Jakub NarebskiDec 11, 2011
  5. Sitaram ChamartyDec 11, 2011
  6. Andreas SchwabDec 11, 2011
  7. Jakub NarebskiDec 11, 2011
  8. Gelonida NDec 11, 2011
  9. Andreas SchwabDec 11, 2011
  10. Martin LanghoffDec 11, 2011
  11. Stefan HallerDec 11, 2011
  12. Gelonida NDec 11, 2011
  13. Martin LanghoffDec 11, 2011
  14. Hallvard B FurusethDec 11, 2011
  15. Stefan HallerDec 12, 2011
  16. Jeff KingDec 12, 2011
  17. Stefan HallerDec 12, 2011
  18. Hallvard Breien FurusethDec 13, 2011
  19. Junio C HamanoDec 12, 2011
  20. Junio C HamanoDec 12, 2011
  21. Gelonida NDec 12, 2011
  22. Gelonida NDec 12, 2011
  23. Sitaram ChamartyDec 17, 2011
  24. Sitaram ChamartyDec 17, 2011
  25. Nazri RamliyDec 19, 2011
  26. Sitaram ChamartyJan 18, 2012
  27. Sitaram ChamartyJan 18, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.