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

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

From
JWJohannes Welsch <johannes.welsch@googlemail.com>
Date
Nov 3, 2026, 15:34 UTC
Message-ID
<CA++gwosYFaOLD5nZjKUUFtp1ryezikqAsD6vu=uqBzOwyszASw@mail.gmail.com>
Hi,
I'd like to propose adding a -s (--switch) option to `git branch`.
It makes sense semantically to create a branch and to also switch to it.
Currently, creating a new branch and immediately switching to it requires:
git switch -c newbranch
I'd like to propose an alternative:
git branch -s newbranch

My reasoning is simple: 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. For me, switching is an additional action when creating the branch, rather than the primary operation.

The proposed option would behave like git switch -c, creating the branch and switching to it in one operation. It would fail if the branch already exists, just as git switch -c does.

I understand that git switch -c already supports this functionality, but I think the alternative syntax would be more intuitive for users who approach the operation from the branch-creation perspective.

Thanks! Johannes

Next: Pushkar Singh
Message 1 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.