git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Carl Baldwin <cnb@fc.hp.com>
Cc: git@vger.kernel.org
Subject: Re: [Question] Fetching a new branch from remote
Date: Thu, 01 Dec 2005 12:09:01 -0800	[thread overview]
Message-ID: <7vk6eoinqa.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <20051128163356.GA8300@hpsvcnb.fc.hp.com> (Carl Baldwin's message of "Mon, 28 Nov 2005 09:33:56 -0700")

Carl Baldwin <cnb@fc.hp.com> writes:

> I would expect this to do it:
>
> % git fetch -f <url> new-branch
>
> But, it doesn't.
>
> Actually, I just noticed that this accomplishes the desired result...
>
> % git fetch <url> new-branch:new-branch

First, '-f' means "allow overriding the fast-forward check when
updating an existing branch".  This can be done per refspec by
saying "+rbranch:lbranch" but if you are fetching more than one
remote branches at once (especially through "remotes" shorthand)
the option can be used to allow override of all of them.

A single token <refspec> defaults to "<refspec>:" (meaning,
"fetch but do not muck with our branches") is deliberate.  When
I get a pull request "please pull from git://u/r/l/ send2junio branch",
I do not "git pull git://u/r/l/ send2junio" right away, but do
"git fetch git://u/r/l/ send2junio" and inspect FETCH_HEAD with
various combinations of "git diff master..FETCH_HEAD" and
friends.  I do _not_ want it to create send2junio branch in my
repository with that.  Also "git pull git://u/r/l/ send2junio"
would internally run "git fetch git://u/r/l/ send2junio" and
then runs merge, and I do not want that to create send2junio
branch in my repository either.  The latter could be prevented by
adding an extra flag to git-fetch to tell it not to default
a single token <refspec> to "<refspec>:<refspec>" and pass that
flag from git-pull, though.

I just found out that the documentation for '-f' flag is simply
missing.  I'd propose to add the following.  Thanks for noticing.

-- >8 --
diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt
index a25d04a..200c9b2 100644
--- a/Documentation/fetch-options.txt
+++ b/Documentation/fetch-options.txt
@@ -4,6 +4,11 @@
 	option old data in `.git/FETCH_HEAD` will be overwritten.
 
 -f, \--force::
+	When `git-fetch` is used with `<rbranch>:<lbranch>`
+	refspec, it refuses to update the local branch
+	`<lbranch>` unless the remote branch `<rbranch>` it
+	fetches is a descendant of `<lbranch>`.  This option
+	overrides that check.
 
 -t, \--tags::
 	By default, the git core utilities will not fetch and store

  reply	other threads:[~2005-12-01 20:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-28 16:33 [Question] Fetching a new branch from remote Carl Baldwin
2005-12-01 20:09 ` Junio C Hamano [this message]
2005-12-01 20:40   ` Jon Loeliger
2005-12-02 15:50   ` Carl Baldwin

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=7vk6eoinqa.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=cnb@fc.hp.com \
    --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.
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).