From: Phillip Wood <phillip.wood123@gmail.com>
To: Stefan Haller <lists@haller-berlin.de>, git@vger.kernel.org
Cc: Derrick Stolee <derrickstolee@github.com>,
Elijah Newren <newren@gmail.com>,
Kristoffer Haugsbakk <code@khaugsbakk.name>
Subject: Re: Should --update-refs exclude refs pointing to the current HEAD?
Date: Mon, 17 Apr 2023 13:14:27 +0100 [thread overview]
Message-ID: <98548a5b-7d30-543b-b943-fd48d8926a33@gmail.com> (raw)
In-Reply-To: <adb7f680-5bfa-6fa5-6d8a-61323fee7f53@haller-berlin.de>
Hi Stefan
On 17/04/2023 09:21, Stefan Haller wrote:
> The --update-refs option of git rebase is so useful that I have it on by
> default in my config. For stacked branches I find it hard to think of
> scenarios where I wouldn't want it.
>
> However, there are cases for non-stacked branches (i.e. other branches
> pointing at the current HEAD) where updating them is undesirable. In
> fact, pretty much always, for me. Two examples, both very similar:
>
> 1. I have a topic branch which is based off of master; I want to make a
> copy of that branch and rebase it onto devel, just to try if that would
> work. I don't want the original branch to be moved along in this case.
>
> 2. I have a topic branch, and I want to make a copy of it to make some
> heavy history rewriting experiments. Again, my interactive rebases would
> always rebase both branches in the same way, not what I want. In this
> case I could work around it by doing the experiments on the original
> branch, creating a tag beforehand that I could reset back to if the
> experiments fail. But maybe I do want to keep both branches around for a
> while for some reason.
>
> Both of these cases could be fixed by --update-refs not touching any
> refs that point to the current HEAD.
I'd use a detached HEAD for the "experimental" rebase and then update
the branch if the rebase was successful. If you really want to use
another branch you could try running "git commit --amend --only" before
rebasing to update the commit date so the two branches don't point to
the same commit.
We could add a command line option to restrict the branches that are
updated by --update-refs but I'm not that enthusiastic about it.
> I'm having a hard time coming up
> with cases where you would ever want those to be updated, in fact.
If a user using stacked branches creates a new branch and then realizes
they need to fix something on the parent before creating any commits on
the new branch they would want both to be updated. e.g.
$ git symbolic-ref HEAD
refs/heads/topic
$ git checkout -b another-topic
# fix a bug in topic - want topic and another-topic to be
# updated
$ git rebase -i --update-refs HEAD~2
Best Wishes
Phillip
> Any opinions?
>
> -Stefan
>
next prev parent reply other threads:[~2023-04-17 12:15 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-17 8:21 Should --update-refs exclude refs pointing to the current HEAD? Stefan Haller
2023-04-17 8:30 ` Stefan Haller
2023-04-17 8:34 ` Kristoffer Haugsbakk
2023-04-17 9:22 ` Stefan Haller
2023-04-18 2:00 ` Felipe Contreras
2023-04-17 12:14 ` Phillip Wood [this message]
2023-04-20 15:27 ` Stefan Haller
2024-03-05 7:40 ` Stefan Haller
2024-03-05 16:22 ` Junio C Hamano
2024-03-06 2:57 ` Elijah Newren
2024-03-06 21:00 ` Stefan Haller
2024-03-07 5:36 ` Elijah Newren
2024-03-07 20:16 ` Stefan Haller
2024-03-09 3:28 ` Elijah Newren
2024-03-12 9:28 ` Stefan Haller
2024-03-07 7:59 ` Kristoffer Haugsbakk
2024-03-07 8:22 ` Elijah Newren
2024-03-24 10:42 ` Stefan Haller
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=98548a5b-7d30-543b-b943-fd48d8926a33@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=code@khaugsbakk.name \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=lists@haller-berlin.de \
--cc=newren@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).