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

Re: [RFC] git branch: add -s/--switch to create and switch to a new branch

From
Pushkar Singh <pushkarkumarsingh1970@gmail.com>
Date
Nov 3, 2026, 17:57 UTC
Message-ID
<20261103175721.1148-1-pushkarkumarsingh1970@gmail.com>
In-Reply-To
<CA++gwosYFaOLD5nZjKUUFtp1ryezikqAsD6vu=uqBzOwyszASw@mail.gmail.com>
Hi Johannes,
[snip]
> when I want to create a new branch, git branch is naturally the command I think of. I want to create a branch and also switch to it.
I get your point, but wouldn't this introduce some overlap between "git branch" and "git switch"?
Currently, we already have "git branch <name>" to create a branch without switching to it, and "git switch <name>" to switch to an existing branch. If you want to create a new branch and switch to it immediately, "git switch -c <name>" already does that.
In fact, the git branch documentation[1] itself suggests using "git switch -c" for exactly this use case.
[snip]
> switching is an additional action when creating the branch, rather than the primary operation.
I understand where you're coming from, but isn't this separation between creating and switching branches one of the reasons git switch was introduced in the first place?
Would adding this functionality to "git branch" make that distinction a little less clear?
Thanks!
Pushkar
---
[1]: https://git-scm.com/docs/git-branch?#_notes
Previous: Johannes WelschNext: Junio C Hamano
Message 2 of 3 in “[RFC] git branch: add -s/--switch to create and switch to a new branch”
  1. Johannes WelschNov 3, 2026
  2. Pushkar SinghNov 3, 2026
  3. Junio C HamanoNov 3, 2026

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.