From: Johan Herland <johan@herland.net>
To: git@vger.kernel.org
Subject: checkout/branch needs some extra safety around the --track option
Date: Tue, 15 Feb 2011 18:52:03 +0100 [thread overview]
Message-ID: <201102151852.03881.johan@herland.net> (raw)
Hi,
I just got a problem report from a Git user a $dayjob, who was confused
about the following output from 'git push' (without arguments, in a
repo with push.default == 'tracking'):
> ----------------------------------------------------------------
> $ git push
> Total 0 (delta 0), reused 0 (delta 0)
> To .
> c9e7b5a..1bf9fed mybranch -> v0.99
> ----------------------------------------------------------------
After some investigations, I could reproduce his problem with the
following commands:
$ git checkout -b mybranch --track v0.99
# Do work on mybranch
$ git push
In other words. The branch was erroneously created with the --track
option, setting up a bogus branch.mybranch config section. When
pushing, this caused the v0.99 tag to be (unexpectedly, to him) updated
in the local repo.
Obviously, this is rooted in user error, but it occurs to me that Git
should be more helpful in this situation. I propose:
1. When given "--track", branch/checkout should verify that the tracked
branch is indeed a branch (preferably a remote branch, although I guess
tracking a local branch can make sense in some situations). At least,
it should deny tracking a _tag_. Tracking a tag simply does not make
sense at all (unless you expect the tag to move, in which case it
should be a branch and not a tag).
2. 'git push' should not move tags by default (not even in your local
repo). Moving tags might be ok if given the -f option (still a remote
repo should be able to object). With the current version of Git, the
following commands will transform an annotated tag into a lightweight
tag with no warning:
$ git config push.default tracking
$ git checkout -b foo --track $annotated_tag
$ git push
...Johan
--
Johan Herland, <johan@herland.net>
www.herland.net
next reply other threads:[~2011-02-15 17:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-15 17:52 Johan Herland [this message]
2011-02-15 20:04 ` checkout/branch needs some extra safety around the --track option Junio C Hamano
2011-02-16 10:46 ` [PATCH] branch/checkout --track: Ensure that upstream branch is indeed a branch Johan Herland
2011-02-16 22:00 ` Junio C Hamano
2011-02-16 23:12 ` [PATCH v2] " Johan Herland
2011-02-18 0:45 ` Martin von Zweigbergk
2011-02-18 4:32 ` 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201102151852.03881.johan@herland.net \
--to=johan@herland.net \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).