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

Re: [PATCH] Disallow creating ambiguous branch names by default

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 19, 2011, 20:49 UTC
Message-ID
<7v1uwh2kks.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CAOTq_ptU2QmPMMZYQLd2MFQ_=_RnADdBnoN5+v4rXh_nmpOcjw@mail.gmail.com>
Conrad Irwin <conrad.irwin@gmail.com> writes:
Show 5 quoted lines
> In the process of changing things around to do this, I noticed that
>
> git checkout -M <foo> <current-branch>
>
> surprisingly works,...
What is "-M" supposed to do???

If you meant "-B", that should work. When I want to rewrite a topic in a non-trivial way, I would often do:

	$ git checkout HEAD^^^
        work to redo what the few commits at the tip should have done,
        creating commits.
        $ git diff @{-1} HEAD
        $ git checkout -B @{-1}

which often happens to be simpler and more flexible than the canned rewriting options "rebase -i" can offer me.

> ... in that you will get a:
>
> $ git rev-parse HEAD@{1}
> warning: Log .git/logs/HEAD has gap after Fri, 19 Aug 2011 02:00:09 -0700

If that is the case, then the codepath to update the reflog is broken. That is not a reason to forbid -B, though.

But because I do not know what you meant by "checkout -M", ...
Previous: Stephen BashNext: Conrad Irwin
Message 8 of 10 in “Disallow creating ambiguous branch names by default”
  1. Disallow creating ambiguous branch names by defaultConrad Irwin, Aug 17, 2011
  2. Junio C HamanoAug 17, 2011
  3. Vijay LakshminarayananAug 18, 2011
  4. Stephen BashAug 18, 2011
  5. Conrad IrwinAug 19, 2011
  6. Conrad IrwinAug 19, 2011
  7. Stephen BashAug 19, 2011
  8. Junio C HamanoAug 19, 2011
  9. Conrad IrwinAug 19, 2011
  10. Junio C HamanoAug 19, 2011

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.