{"thread":{"id":"2702","subject":"[Question] Fetching a new branch from remote","startedAt":"2005-11-28T16:33:56Z","lastAt":"2005-12-02T15:50:47Z","messageCount":4,"participants":["Carl Baldwin","Junio C Hamano","Jon Loeliger"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"12884","messageId":"20051128163356.GA8300@hpsvcnb.fc.hp.com","threadId":"2702","inReplyTo":null,"subject":"[Question] Fetching a new branch from remote","fromName":"Carl Baldwin","fromEmail":"cnb@fc.hp.com","sentAt":"2005-11-28T16:33:56Z","receivedAt":"2005-11-28T16:33:56Z","isPatch":false,"sender":{"key":"cnb@fc.hp.com","avatar":null},"body":"Greetings,\n\nI have a short question about git fetch.  Say there is a new branch,\ncall it 'new-branch' in a remote repository.  I am interested in this\nbranch and want to fetch it to 'new-branch' in my local to track its\nprogress.\n\nI would expect this to do it:\n\n% git fetch -f <url> new-branch\n\nBut, it doesn't.\n\nActually, I just noticed that this accomplishes the desired result...\n\n% git fetch <url> new-branch:new-branch\n\nI also just noticed that the man pages only says that '-f' works on\ntags.  Should it work on branches?  Either way, it wasn't clear to me\nhow to fetch a new branch from a remote and store it under the same name\nlocally.  In my opinion, git fetch -f should do this if given a\nbranchname from the remote.\n\nCarl\n\n-- \n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n Carl Baldwin                        Systems VLSI Laboratory\n Hewlett Packard Company\n MS 88                               work: 970 898-1523\n 3404 E. Harmony Rd.                 work: Carl.N.Baldwin@hp.com\n Fort Collins, CO 80525              home: Carl@ecBaldwin.net\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"},{"id":"13057","messageId":"7vk6eoinqa.fsf@assigned-by-dhcp.cox.net","threadId":"2702","inReplyTo":"20051128163356.GA8300@hpsvcnb.fc.hp.com","subject":"Re: [Question] Fetching a new branch from remote","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-01T20:09:01Z","receivedAt":"2005-12-01T20:09:01Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Carl Baldwin <cnb@fc.hp.com> writes:\n\n> I would expect this to do it:\n>\n> % git fetch -f <url> new-branch\n>\n> But, it doesn't.\n>\n> Actually, I just noticed that this accomplishes the desired result...\n>\n> % git fetch <url> new-branch:new-branch\n\nFirst, '-f' means \"allow overriding the fast-forward check when\nupdating an existing branch\".  This can be done per refspec by\nsaying \"+rbranch:lbranch\" but if you are fetching more than one\nremote branches at once (especially through \"remotes\" shorthand)\nthe option can be used to allow override of all of them.\n\nA single token <refspec> defaults to \"<refspec>:\" (meaning,\n\"fetch but do not muck with our branches\") is deliberate.  When\nI get a pull request \"please pull from git://u/r/l/ send2junio branch\",\nI do not \"git pull git://u/r/l/ send2junio\" right away, but do\n\"git fetch git://u/r/l/ send2junio\" and inspect FETCH_HEAD with\nvarious combinations of \"git diff master..FETCH_HEAD\" and\nfriends.  I do _not_ want it to create send2junio branch in my\nrepository with that.  Also \"git pull git://u/r/l/ send2junio\"\nwould internally run \"git fetch git://u/r/l/ send2junio\" and\nthen runs merge, and I do not want that to create send2junio\nbranch in my repository either.  The latter could be prevented by\nadding an extra flag to git-fetch to tell it not to default\na single token <refspec> to \"<refspec>:<refspec>\" and pass that\nflag from git-pull, though.\n\nI just found out that the documentation for '-f' flag is simply\nmissing.  I'd propose to add the following.  Thanks for noticing.\n\n-- >8 --\ndiff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt\nindex a25d04a..200c9b2 100644\n--- a/Documentation/fetch-options.txt\n+++ b/Documentation/fetch-options.txt\n@@ -4,6 +4,11 @@\n \toption old data in `.git/FETCH_HEAD` will be overwritten.\n \n -f, \\--force::\n+\tWhen `git-fetch` is used with `<rbranch>:<lbranch>`\n+\trefspec, it refuses to update the local branch\n+\t`<lbranch>` unless the remote branch `<rbranch>` it\n+\tfetches is a descendant of `<lbranch>`.  This option\n+\toverrides that check.\n \n -t, \\--tags::\n \tBy default, the git core utilities will not fetch and store\n"},{"id":"13061","messageId":"1133469656.30767.76.camel@cashmere.sps.mot.com","threadId":"2702","inReplyTo":"7vk6eoinqa.fsf@assigned-by-dhcp.cox.net","subject":"Re: [Question] Fetching a new branch from remote","fromName":"Jon Loeliger","fromEmail":"jdl@freescale.com","sentAt":"2005-12-01T20:40:56Z","receivedAt":"2005-12-01T20:40:56Z","isPatch":false,"sender":{"key":"jdl@jdl.com","avatar":"https://gravatar.com/avatar/75ce9a10b151acd2c28ec4ab2136dba7b2ff1634530bd04b155981a749d08a64?d=mp&s=160"},"body":"On Thu, 2005-12-01 at 14:09, Junio C Hamano wrote:\n\n> \n> I just found out that the documentation for '-f' flag is simply\n> missing.  I'd propose to add the following.  Thanks for noticing.\n\nHmm.  Apologies.  I had mentioned it back here, but\ndidn't know what it did and so didn't document it:\n\n        \n    From: \tJon Loeliger <jdl@freescale.com>\n    To: \tgit@vger.kernel.org\n    Subject: \t[PATCH] Add --tags documentation, scraped from JC mail.\n    Date: \tMon, 7 Nov 2005 07:03:30 -0700 \t\n\n    Signed-off-by: Jon Loeliger <jdl@freescale.com>\n\n    ---\n\n    Thin territory here for me.  Feel free to alter if not right! :-)\n    Also notice the lonely --force option still...\n"},{"id":"13107","messageId":"20051202155047.GA14547@hpsvcnb.fc.hp.com","threadId":"2702","inReplyTo":"7vk6eoinqa.fsf@assigned-by-dhcp.cox.net","subject":"Re: [Question] Fetching a new branch from remote","fromName":"Carl Baldwin","fromEmail":"cnb@fc.hp.com","sentAt":"2005-12-02T15:50:47Z","receivedAt":"2005-12-02T15:50:47Z","isPatch":false,"sender":{"key":"cnb@fc.hp.com","avatar":null},"body":"The documentation below does make this more clear.  Now that you've\nexplained it I can see it useful to fetch a remote head without creating\na local one.  I simply hadn't thought of this scenerio.\n\nThank you for the explanation.\n\nCheers,\nCarl\n\nOn Thu, Dec 01, 2005 at 12:09:01PM -0800, Junio C Hamano wrote:\n> Carl Baldwin <cnb@fc.hp.com> writes:\n> \n> > I would expect this to do it:\n> >\n> > % git fetch -f <url> new-branch\n> >\n> > But, it doesn't.\n> >\n> > Actually, I just noticed that this accomplishes the desired result...\n> >\n> > % git fetch <url> new-branch:new-branch\n> \n> First, '-f' means \"allow overriding the fast-forward check when\n> updating an existing branch\".  This can be done per refspec by\n> saying \"+rbranch:lbranch\" but if you are fetching more than one\n> remote branches at once (especially through \"remotes\" shorthand)\n> the option can be used to allow override of all of them.\n> \n> A single token <refspec> defaults to \"<refspec>:\" (meaning,\n> \"fetch but do not muck with our branches\") is deliberate.  When\n> I get a pull request \"please pull from git://u/r/l/ send2junio branch\",\n> I do not \"git pull git://u/r/l/ send2junio\" right away, but do\n> \"git fetch git://u/r/l/ send2junio\" and inspect FETCH_HEAD with\n> various combinations of \"git diff master..FETCH_HEAD\" and\n> friends.  I do _not_ want it to create send2junio branch in my\n> repository with that.  Also \"git pull git://u/r/l/ send2junio\"\n> would internally run \"git fetch git://u/r/l/ send2junio\" and\n> then runs merge, and I do not want that to create send2junio\n> branch in my repository either.  The latter could be prevented by\n> adding an extra flag to git-fetch to tell it not to default\n> a single token <refspec> to \"<refspec>:<refspec>\" and pass that\n> flag from git-pull, though.\n> \n> I just found out that the documentation for '-f' flag is simply\n> missing.  I'd propose to add the following.  Thanks for noticing.\n> \n> -- >8 --\n> diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt\n> index a25d04a..200c9b2 100644\n> --- a/Documentation/fetch-options.txt\n> +++ b/Documentation/fetch-options.txt\n> @@ -4,6 +4,11 @@\n>  \toption old data in `.git/FETCH_HEAD` will be overwritten.\n>  \n>  -f, \\--force::\n> +\tWhen `git-fetch` is used with `<rbranch>:<lbranch>`\n> +\trefspec, it refuses to update the local branch\n> +\t`<lbranch>` unless the remote branch `<rbranch>` it\n> +\tfetches is a descendant of `<lbranch>`.  This option\n> +\toverrides that check.\n>  \n>  -t, \\--tags::\n>  \tBy default, the git core utilities will not fetch and store\n> \n> \n\n-- \n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n Carl Baldwin                        Systems VLSI Laboratory\n Hewlett Packard Company\n MS 88                               work: 970 898-1523\n 3404 E. Harmony Rd.                 work: Carl.N.Baldwin@hp.com\n Fort Collins, CO 80525              home: Carl@ecBaldwin.net\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n"}]}