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

3 messages from 2026-11-03 to 2026-11-03. Participants: Johannes Welsch, Pushkar Singh, Junio C Hamano.
Thread: https://gitlist.dev/t/66757

## Johannes Welsch, 2026-11-03 15:34

Subject: [RFC] git branch: add -s/--switch to create and switch to a new branch
Message-ID: <CA++gwosYFaOLD5nZjKUUFtp1ryezikqAsD6vu=uqBzOwyszASw@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2B%2BgwosYFaOLD5nZjKUUFtp1ryezikqAsD6vu%3DuqBzOwyszASw%40mail.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


```

## Pushkar Singh, 2026-11-03 17:57

Subject: Re: [RFC] git branch: add -s/--switch to create and switch to a new branch
Message-ID: <20261103175721.1148-1-pushkarkumarsingh1970@gmail.com>
URL: https://gitlist.dev/e/20261103175721.1148-1-pushkarkumarsingh1970%40gmail.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


```

## Junio C Hamano, 2026-11-03 19:46

Subject: Re: [RFC] git branch: add -s/--switch to create and switch to a new branch
Message-ID: <xmqq7bit7l68.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqq7bit7l68.fsf%40gitster.g
In-Reply-To: <CA++gwosYFaOLD5nZjKUUFtp1ryezikqAsD6vu=uqBzOwyszASw@mail.gmail.com>

```
Johannes Welsch <johannes.welsch@googlemail.com> writes:

> 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.

Why is "git checkout -b <new-branch-name> [<where-the-branch-begins]" 
not sufficient?


```
