🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #2258

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

#2258
From: Pushkar Singh
Date: Tue, 03 Nov 2026 17:57
26 lines
11584 bytes
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
Technical Details
Message-ID: <20261103175721.1148-1-pushkarkumarsingh1970@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74333-linux-kernel-git=dewy.ru
References: <CA++gwosYFaOLD5nZjKUUFtp1ryezikqAsD6vu=uqBzOwyszASw@mail.gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74333-linux-kernel-git=dewy.ru
From: pushkarkumarsingh1970@gmail.com (Pushkar Singh)
Newsgroups: linux.kernel.git
Subject: Re: [RFC] git branch: add -s/--switch to create and switch to a new branch
Date: Tue,  3 Nov 2026 17:57:21 +0000
Organization: Usenet Network
Message-ID: <20261103175721.1148-1-pushkarkumarsingh1970@gmail.com>
References: <CA++gwosYFaOLD5nZjKUUFtp1ryezikqAsD6vu=uqBzOwyszASw@mail.gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3238449"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:7izr4TFIdch05EEI8gTfEhRC9eA= sha256:1MGyYdaM/dj1GmIf+UW7dl6N7XwTjaHBXH9Dn7Khdr4=
	sha1:JWzA2YN8aujVnoVlN6yG1HChkhk= sha256:cO2NApyxgADjzn9ueCfooRqu6eyxSjFp2YUyoO3MqqA=
List-ID: <git.vger.kernel.org>
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 631A91129C5; Tue,  3 Nov 2026 22:04:24 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: 1.609
X-Spam-Level: *
X-Spam-Status: No, score=1.609 tagged_above=-9999 required=6.31
	tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_SBL_CSS=3.558,
	SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=no autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id quLwtFjpI8sS;
	Tue,  3 Nov 2026 22:04:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=git+bounces-74333-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 0F2471129C3; Tue,  3 Nov 2026 22:04:12 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 38C8B46F16; Tue,  3 Nov 2026 17:57:48 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793728664;
	b=zdBMU6/JDbvFw4YBNQSTeAiLyvBcgS2Kpb2f72vMcAKAxyHs0o9ZHi4qEnEhignGyCQg
	 Tb5G3J0b40J38+uHS9d1bUeFPk0MpbrUGDQC9cvWmiqJOyGOdnodJZE/Ll0aTSnOIjwHL
	 T01NxZd3VYhQ7ac65BqOSnhsgAK1Q8Gielyfeo+D/Ts/VRlrodvFBIqB7yH8WMvYn8QHH
	 9+zwxCYS0EqCvHZYpCTuNK8LytDN/JIA+1yO1fJ1l1F35O91oJKEiov6CN2E5PfPw6nKf
	 u0R+CWkOmI/l5zXkYZkLMVc1DcORQB6plhWCQlsz+qyi4jYPKSPIpovwbq9ZPF1t3Sw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793728664;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
	 Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding;
	bh=gatpHxLQ2giViMKex2a90km4JMusQK8pNLcKw0JhhiU=;
	b=yT1G9UUYq+vFbO2xqhYMPQwYlofoDkLvp0CgYZuMsnP3UQpRg/Pofo1VeQhtrpk9Ifq1
	 OnLC+w3SDIRMnfq/odVFnUoEkL2Sj+G6gf9L5xiCY52bR4X30ADM+1vBMXwjDZ5Y3+F2Z
	 8L13aIh0KueiQQg3Nna8N0pmPZfHRQCumc+AcrROh6o/yY9dS7PirmK6RfpPfKXnithzW
	 flj20aMfD12q2UYZBEsFc2rk4z+hV4e5FW0gx+KnRtXjfSfg+x8l3gYQIQEe2YoNvhQkA
	 fc3nBDSaLg9R8qdIhUdXJKqLFjz8Q4zPtaouE3KcoCmHob3QpyP5GLioaIEgN3T+WwQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=KDaX5HYl;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 85C1F606A32F;
	Tue,  3 Nov 2026 17:57:44 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=KDaX5HYl
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.43
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793728663;
	b=1+0Qv6qovUaFxZ049SGe5HWrFTZkQDgbJwpxVCn5uSL1CUHruQswP3Jn3Bg2/r+1ytoB
	 owvkqrO+svyQ8FUksJlsK4gTCLDIGt6UcHsuvjZNGEII56qxdpz6QJohekpWq+LNNGt51
	 PYF5QBw/kRKpoy5Q+rOkkjhKiF4wmfEpB6U5w7y3b5Ao+8rcCghP06ZveuO8D2a9qGM6m
	 uNWX7Qk5ysv331aUWRbKKMCIMKnR/QPAh3Ug8iPpcw43xMqTUFMdnNFE2NK6iYIqadPck
	 Tsf4cx1415ClKQS0IigeV72BG3AuPqifygpJkiSAE7zkC3Vg2Geypz1m5/PWaNV9ymg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793728663;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
	 Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
	 Content-Transfer-Encoding;
	bh=gatpHxLQ2giViMKex2a90km4JMusQK8pNLcKw0JhhiU=;
	b=Sku2urMElkdH2XfnClf/BtBHD3rbHL9voePZscV08x7DhW9cwuEOGbE7bFcmAo5yy8Js
	 6Cv8S9lS/jHS7jdVA/l02UYNQI6NEWiLXXWGyHKGVKi7l9YJZt9fR9SG6P4fDX90HK3ID
	 rDd5aUJPhNAwSPXFX4AcgEMhzf+HWQoQaQimCn6qHs9DdAwq5ZLgbLQvpBvTNo8R/R1DL
	 wVUhzFzZHqOBaG6kbhv8rpzkV3MaKMzfdFEvU0afqljujuausiEPuhuAAmcVFQ1VbMqaS
	 fNHeLS1X4Uqrkia2hzwAHak8u6kPS5A24ex3I1ucFlraNCipaLUrJnzjcoonagaD9Qw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=KDaX5HYl;
	arc=none smtp.remote-ip=74.125.82.43
X-Received: from mail-dl1-f43.google.com (mail-dl1-f43.google.com [74.125.82.43])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56E77606A328
	for <git@vger.kernel.org>; Tue,  3 Nov 2026 17:57:43 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 56E77606A328
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dl1-f43.google.com with SMTP id a92af1059eb24-170135e43c7so2856933c88.0
        for <git@vger.kernel.org>; Tue, 03 Nov 2026 09:57:43 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1793728662; x=1794333462; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=gatpHxLQ2giViMKex2a90km4JMusQK8pNLcKw0JhhiU=;
        b=KDaX5HYlNa3QkQsfFOkl5tj7wpsyAM9Z+DhA7HBVxOeYFGr+WaEsA1kTfVkuPa2jd7
         ZjyzXzeB9yZDiaSX/V+Xe2m7cUHIzjHT+KgF4nyAqlwaI2oov0VF7A1+5wLOKQP4iKUv
         Z0TFQDYwpAUaQSjGhqYS/QrSYHszdtO3ft+v3EtI5TiS/5MCmaAj7T4AVK1nveKhf7YR
         DyB9+QUAH7ekSVriQdZBApFMrh9RmaVVlIY6CHPIkIJb0y4MdfnlYQhj6fEh5Yq2grnt
         KtUiJKUBPE0kev1e72DwK3cVo+PWWmFjRZkP1UlfnXQtwWNnByi8vybfTTcYvrgisXnq
         VCqw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1793728662; x=1794333462;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
         :to:cc:subject:date:message-id:reply-to:content-type;
        bh=gatpHxLQ2giViMKex2a90km4JMusQK8pNLcKw0JhhiU=;
        b=RaCHnE/8yLhhqIaAwE43K+FUw7VxWFjLmPqdFy0vMCVje3NuHOKKf42snhkelSRLVC
         4/mHGTOawMJ4y8YQStGrrTY6FXRQClWcKfhpB/wmJdfH1W+6G0CT3s28+5IVB8LBvPql
         n5sHXWuzkNTsFNhmZjMX1pEhFdY9KnqZzEmFBNFfY609yjORcwKQFU9y2nk/WKJFb/ww
         ucE6CbPJfbUscaD5+5sI2NmLpF4XoIGOlePF/vIxZ0OZ1+wVfXstt69rTIU3WdmAjJXI
         1af/MyzZ0fqhqkY2fr1essqHMs47D4v25lZ+DAXB5Hiakaes6DX8qO/1L3N+LY/QwqG4
         uZ/A==
X-Gm-Message-State: APuU4Z9eFcFoYIvRI2EO+bQKPRaMOBMPQhGwEaMybVaYtO2MwTcX7wA7
	eYOxHOP/fIlLWOzSBM/qsnvvSZL/sdBt4iccEzxo/7KqPJjL+R1oMLa7Arbweg==
X-Gm-Gg: AYBFou2j9OmExXrXgZvvNr0g3YJ+8/zLmkJqQqliz76ePUNeWx0yeoUyShOu16TvbN/
	KH68F10J2cMCH0i9PCWnwJufVMncK16Y2w7kd+MzlEW5acMmVgYhpmuMKSo20PaIprQ03rlFuM6
	I/V5joznqyWgjSTF5Iw4xyCcGLCvAz6qcSe6ml2wLW6FqzIJqJSEE5Ij8tpvzHjKGAxlvZ4F83e
	xSDV/IW+N1QbaDcSEMoAekKpqVoZihaTQdWkxB+/o4cP1PfLmjf9S+zXctZQRIo8qw943nkmONY
	cAA5BUPgpBp7tMrjyn+TnZh9zlWFnO6o5rphJV0LGJybxMGCcMYHRuat5u7nAV0dWvLKGH/xNwb
	ilXpXp2GOF9OwG0HA7nwbUL9n+4fGQA/2EYcCfp8gpbihrprvRboL1LDhhMqugzKAEQokTc3dd6
	Nk50413nAXKFK36H00gLDs0bLgqCzmRBZd0KX2DzhkfAJ6PuSyOWqJ38qKyGjmE38unWA3NAFaC
	eEjfshKNljUV6vwQfLFo8llxFJByReq5kX65H5Z5xh2TK9bZ5MT5FGnu8NqRCTcWaX91Q4nJsmK
	W0b3AsiL/XQ+Ci9ENuAHhRepw/0nPMaktv7lFvO7kwL4rd5rYg==
X-Received: by 2002:a05:7022:208a:b0:1b0:4272:4282 with SMTP id a92af1059eb24-1b042725256mr12685291c88.17.1793728662202;
        Tue, 03 Nov 2026 09:57:42 -0800 (PST)
X-Received: from HP-V15.xu.edu.in ([125.22.10.135])
        by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b245c2c2ddsm477617c88.10.2026.11.03.09.57.39
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Tue, 03 Nov 2026 09:57:41 -0800 (PST)
X-Cc: git@vger.kernel.org
X-Mailer: git-send-email 2.53.0
X-In-Reply-To: <CA++gwosYFaOLD5nZjKUUFtp1ryezikqAsD6vu=uqBzOwyszASw@mail.gmail.com>
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list