All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Andrea Stacchiotti via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,  Andrea Stacchiotti <andreastacchiotti@gmail.com>
Subject: Re: [PATCH] branch: move multiple branches in a single --force
Date: Tue, 10 Jun 2025 14:25:53 -0700	[thread overview]
Message-ID: <xmqq7c1jmgpq.fsf@gitster.g> (raw)
In-Reply-To: <pull.1992.git.git.1749546464346.gitgitgadget@gmail.com> (Andrea Stacchiotti via GitGitGadget's message of "Tue, 10 Jun 2025 09:07:44 +0000")

"Andrea Stacchiotti via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> From: Andrea Stacchiotti <andreastacchiotti@gmail.com>
>
> Using either the 1-arg or 2-args form of --force
> it is possible to only move one branch at a time,
> to HEAD and <arg2> respectively.

If you are renaming (or "moving") a branch that is not checked out
anywhere to a new name that is not in use, you do not even need to
force.  You can just do:

    git branch -m old new

You are not moving branches without "-m".

What you are doing is to point a branch A to point at a commit X
with

    git branch A X

Your proposed log message talks about "--force" too much; if you are
creating a branch, you need "--force" only when the name you want to
use is already taken.  Pointing the branch tip to a commit is not
inherently tied to "--force", but your description gives a false
impression that you are adding a special feature when "--force" is
used.  The proposed log message needs rewritten.

If there is not yet a branch A, you do not even need "--force" on
this command line.  Also take a special note that "X" does not have
to be a branch name.  It only has to resolve to a commit, so this is
also valid:

    git branch [--force] A X~4

I can understand that it may appear to be handy to be able to set
multiple branches at the same time with

    git branch A X~4 B X~3 C X~2		(* does not exist *)

with or without "--force".  If none of A, B, or C exist, they can be
created from these three comits X~4, X~3, and X~2.

Or you could propose a different syntax to create branches pointing
at the same commit

    git branch A B C origin/master		(* does not exist *)

But either syntax to create multiple branches feel somewhat
inadequate.  What should happen to their associated configuration
data like branch.A.remote and branch.B.merge?  Should they all point
at the same remote & a branch at the remote?  How would that make
having multiple of them useful?


  reply	other threads:[~2025-06-10 21:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-10  9:07 [PATCH] branch: move multiple branches in a single --force Andrea Stacchiotti via GitGitGadget
2025-06-10 21:25 ` Junio C Hamano [this message]
2025-06-10 22:17   ` Andrea Stacchiotti
2025-06-11  0:22     ` Junio C Hamano
2025-06-11  8:34       ` Andrea Stacchiotti
2025-06-11 15:26         ` Junio C Hamano
2025-06-12  0:19           ` Andrea Stacchiotti
2025-06-12  9:55             ` Junio C Hamano
2025-06-12 15:48               ` Junio C Hamano
2025-06-12 16:51                 ` Andrea Stacchiotti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq7c1jmgpq.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=andreastacchiotti@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.