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

[RFC/FR] Should "git checkout (-B|-b) branch master...branch" work?

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 21, 2012, 15:58 UTC
Message-ID
<7v8v8r2y8s.fsf@alter.siamese.dyndns.org>

When you want to redo a branch forked from another branch (say 'master'), a handy way to work is to first detach HEAD at the previous fork point:

    $ git checkout master...branch

and build an updated history on top of this state. Once you are done, you can verify your results with commands like:

    $ git show-branch branch HEAD
    $ git diff branch HEAD
and then finish it off with:
    $ git checkout -B branch

This way, you can keep the history of the previous round on 'branch' until you are done with the new history you build on the detached HEAD state, and if you do not like updated history, you can reset back to branch@{1} easily.

But you may not even need to have such an easy access to the old history and just want to restart, with:

    $ git checkout -B branch <old fork point>

Unfortunately, master...branch syntax does not seem to work for specifying the "old fork point" for this purpose, even though we have special case to support the syntax in the "detach at that commit" case (the first command line example in this message).

Perhaps we should teach the <start-point> parser this syntax as well?

Next: Martin von Zweigbergk
Message 1 of 7 in “[RFC/FR] Should "git checkout (-B|-b) branch master...branch" work?”
  1. Junio C HamanoDec 21, 2012
  2. Fwd: [RFC/FR] Should "git checkout (-B|-b) branch master...branch" work?Martin von Zweigbergk, Dec 21, 2012
  3. Junio C HamanoDec 21, 2012
  4. Michael HaggertyDec 21, 2012
  5. Martin von ZweigbergkDec 21, 2012
  6. Junio C HamanoDec 21, 2012
  7. Michael HaggertyDec 21, 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.