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

Re: [PATCH 1/2] Allow users to require source branch on git-checkout -b.

From
Junio C Hamano <junkio@cox.net>
Date
Dec 7, 2006, 19:48 UTC
Message-ID
<7vlkljsd1k.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20061207100152.GA12966@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> writes:
Show 7 quoted lines
> I have recently observed a rather large number of users who forget
> to specify the base revision when they start a new branch with
> git-checkout -b.  Many of these users are shocked many hours and
> commits later when their prior branch is now also part of the new
> branch.  Nasty words about Git usually follow the discovery.
>
> This introduces a new config option: checkout.requireSourceBranch,
I'm not sure about this.

Often after you started to code something while on 'master' you realize that work is not trivial and needs its own branch and then "checkout -b" without having to say 'master' (or HEAD) is very handy.

I think requring an explicit fork-point when you are _not_ on 'master' might be a better behaviour.

In other words, you allow "checkout -b" (and "branch") to default to HEAD only while on the branches marked in your configuration file:

Then:
	[branch]
        	allowbranchbydefault = main
        	allowbranchbydefault = test

can be used to say "while on 'main' and 'test' branch, 'git checkout -b' and 'git branch' without branch point defaults to the current branch".

You could turn it around and make it a per-branch configuration, like:

	[branch "main"]
        	allowbranchbydefault = true
Previous: Shawn O. PearceNext: Shawn Pearce
Message 2 of 12 in “Allow users to require source branch on git-checkout -b.”
  1. 1/2 Allow users to require source branch on git-checkout -b.Shawn O. Pearce, Dec 7, 2006
  2. Junio C HamanoDec 7, 2006
  3. Shawn PearceDec 7, 2006
  4. Junio C HamanoDec 7, 2006
  5. J. Bruce FieldsDec 7, 2006
  6. Shawn PearceDec 7, 2006
  7. J. Bruce FieldsDec 8, 2006
  8. Shawn PearceDec 8, 2006
  9. J. Bruce FieldsDec 8, 2006
  10. Shawn PearceDec 8, 2006
  11. Junio C HamanoDec 8, 2006
  12. J. Bruce FieldsDec 8, 2006

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.