From: Konstantin Khomoutov <flatworm@users•sourceforge.net>
To: Ryan Lortie <desrt@desrt•ca>
Cc: git@vger•kernel.org
Subject: Re: 'git branch' when origin branch with same name exists
Date: Tue, 19 Jun 2012 20:06:48 +0400 [thread overview]
Message-ID: <20120619200648.2cc8a861.kostix@domain007.com> (raw)
In-Reply-To: <4FE091FB.7020202@desrt.ca>
On Tue, 19 Jun 2012 10:51:39 -0400
Ryan Lortie <desrt@desrt•ca> wrote:
> After helping someone on IRC who got themselves into a bit of a
> problem, I have a feature request for git.
>
> In this case, the user wanted to checkout a branch of a module. They
> did:
>
> git clone git://git.gnome.org/gtk+
> cd gtk+
> git branch gtk-3-4
>
> Obviously this is a user error, but it's a pretty innocent one, and
> puts the user in a bad state.
> When they figure they should have
> typed "git checkout gtk-3-4" it is already too late -- they will be
> taken onto their locally-created copy of the master branch.
How bad this state really is?
The user is free to do
$ git branch -m gtk-3-4 mygtk-3-4
at any time after the error was detected.
> So feature request: 'git branch' should not allow creating a local
> branch that has the same name as a branch that already exists on
> 'origin' (or any remote?) without some sort of --force flag. It
> could instead helpfully say:
[...]
> or something like that.
This would not protect from the obvious case when a branch has been
created on the remote (by someone else) but has not been fetched yet
and so the local repo does not know a branch with "conflicting"
name do exist.
> Thoughts?
Your intention is good but I think a safety net of the kind you
propose would be slightly over the top.
Basically you're trying to compensate for the user error who
thinks the "branch" command should take her to an already existing
branch while it does something completely different.
Hence preventing the `git branch gtk-3-4` command from completion
should there be a remote-tracking branch of the same name is just wrong
IMO. On the other hand, posting a hint might be OK. I'm talking about
something like this:
$ git branch gtk-3-4
The remote "origin" has the branch of the same name.
The created branch is not set to track it.
Such a hint would state the obvious thing but it would alert a user
who would not expect it (and hopefully make her google or ask for
assistance using this hint's message).
Anyway, this will make each call to git-branch to perform a crawl over
the refs/heads hierarchy which, I think, is not worth the result.
next prev parent reply other threads:[~2012-06-19 16:06 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-19 14:51 'git branch' when origin branch with same name exists Ryan Lortie
2012-06-19 15:18 ` jaseem abid
2012-06-19 15:35 ` Michael Schubert
2012-06-19 15:54 ` Ryan Lortie
2012-06-19 16:17 ` Philippe Vaucher
2012-06-19 15:57 ` Angus Hammond
2012-06-19 16:06 ` Konstantin Khomoutov [this message]
2012-06-19 17:06 ` Ryan Lortie
2012-06-20 8:31 ` Andreas Ericsson
2012-06-19 17:21 ` Thomas Rast
2012-06-19 18:31 ` Junio C Hamano
2012-06-19 20:44 ` Ryan Lortie
2012-06-19 21:32 ` Junio C Hamano
2012-06-19 21:50 ` Ryan Lortie
2012-06-19 23:21 ` Phil Hord
2012-06-20 17:32 ` Junio C Hamano
2012-06-20 17:51 ` Matthieu Moy
2012-06-20 18:07 ` Junio C Hamano
2012-06-19 18:22 ` Junio C Hamano
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=20120619200648.2cc8a861.kostix@domain007.com \
--to=flatworm@users$(echo .)sourceforge.net \
--cc=desrt@desrt$(echo .)ca \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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