{"thread":{"id":"14562","subject":"git pull versus fetch/merge","startedAt":"2008-07-21T09:11:50Z","lastAt":"2008-07-21T11:39:37Z","messageCount":8,"participants":["Rene Herman","Björn Steinbrink","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"84162","messageId":"488452D6.1060508@keyaccess.nl","threadId":"14562","inReplyTo":null,"subject":"git pull versus fetch/merge","fromName":"Rene Herman","fromEmail":"rene.herman@keyaccess.nl","sentAt":"2008-07-21T09:11:50Z","receivedAt":"2008-07-21T09:11:50Z","isPatch":false,"sender":{"key":"rene.herman@keyaccess.nl","avatar":null},"body":"Good day.\n\nA while ago I was here asking about \"git pull\" versus \"git merge\" for \nlocal branches -- now I see a difference for remote ones that I'm not \nsure should be there.\n\nI gathered before that \"git pull <remote> <branch>\" should basically be \nshorthand for \"git fetch <remote>, git merge <remote>/<branch>\". Is that \ncorrect?\n\nI'm seeing a problem I believe with a specific repository:\n\nrene@7ixe4:~/src/linux/7ixe4$ git remote show tiwai\n* remote tiwai\n   URL: git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6\n   Tracked remote branches\n     devel dma-fix for-linus master upstream\n\nwith \"git pull tiwai devel\" everything goes well:\n\nrene@7ixe4:~/src/linux/7ixe4$ git status\n# On branch master\nnothing to commit (working directory clean)\nrene@7ixe4:~/src/linux/7ixe4$ git branch tmp0 v2.6.26\nrene@7ixe4:~/src/linux/7ixe4$ git branch tmp1 v2.6.26\nrene@7ixe4:~/src/linux/7ixe4$ git checkout tmp0\nSwitched to branch \"tmp0\"\nrene@7ixe4:~/src/linux/7ixe4$ git pull tiwai devel\nUpdating bce7f79..e0bf09b\nFast forward\n  Documentation/sound/alsa/ALSA-Configuration.txt    |   17 +-\n  [ ... ]\n\nand I get a clean merge. On the other hand, if I try to do this with a \nfetch/merge, I get:\n\nrene@7ixe4:~/src/linux/7ixe4$ git checkout tmp1\nSwitched to branch \"tmp1\"\nrene@7ixe4:~/src/linux/7ixe4$ git fetch tiwai\n From git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6\n  ! [rejected]        devel      -> tiwai/devel  (non fast forward)\n  ! [rejected]        dma-fix    -> tiwai/dma-fix  (non fast forward)\n  ! [rejected]        master     -> tiwai/master  (non fast forward)\nrene@7ixe4:~/src/linux/7ixe4$ git merge tiwai/devel\nAuto-merged sound/pci/ac97/ac97_patch.c\nAuto-merged sound/pci/emu10k1/emu10k1_main.c\nAuto-merged sound/pci/hda/patch_analog.c\nAuto-merged sound/pci/hda/patch_realtek.c\nCONFLICT (content): Merge conflict in sound/pci/hda/patch_realtek.c\nAuto-merged sound/pci/hda/patch_sigmatel.c\nAutomatic merge failed; fix conflicts and then commit the result.\n\nand me no happy...\n\nIt probably has something to do with that \" ! [rejected]\" but what is \nthat about? Is the repo bad? (and if so, I suspect owner will want to \nknow how to avoid it in the future).\n\nAnd if it is bad, should I be seeing something with the pull method \nalso? Moreover... can I now trust my tmp0 branch?\n\nRene.\n"},{"id":"84170","messageId":"20080721102320.GA19776@atjola.homenet","threadId":"14562","inReplyTo":"488452D6.1060508@keyaccess.nl","subject":"Re: git pull versus fetch/merge","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-07-21T10:23:20Z","receivedAt":"2008-07-21T10:23:20Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.07.21 11:11:50 +0200, Rene Herman wrote:\n> Good day.\n>\n> A while ago I was here asking about \"git pull\" versus \"git merge\" for  \n> local branches -- now I see a difference for remote ones that I'm not  \n> sure should be there.\n>\n> I gathered before that \"git pull <remote> <branch>\" should basically be  \n> shorthand for \"git fetch <remote>, git merge <remote>/<branch>\". Is that  \n> correct?\n>\n> I'm seeing a problem I believe with a specific repository:\n>\n> rene@7ixe4:~/src/linux/7ixe4$ git remote show tiwai\n> * remote tiwai\n>   URL: git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6\n>   Tracked remote branches\n>     devel dma-fix for-linus master upstream\n>\n> with \"git pull tiwai devel\" everything goes well:\n>\n> rene@7ixe4:~/src/linux/7ixe4$ git status\n> # On branch master\n> nothing to commit (working directory clean)\n> rene@7ixe4:~/src/linux/7ixe4$ git branch tmp0 v2.6.26\n> rene@7ixe4:~/src/linux/7ixe4$ git branch tmp1 v2.6.26\n> rene@7ixe4:~/src/linux/7ixe4$ git checkout tmp0\n> Switched to branch \"tmp0\"\n> rene@7ixe4:~/src/linux/7ixe4$ git pull tiwai devel\n> Updating bce7f79..e0bf09b\n> Fast forward\n>  Documentation/sound/alsa/ALSA-Configuration.txt    |   17 +-\n>  [ ... ]\n>\n> and I get a clean merge.\n\n\"git pull remote branch\" does \"git fetch remote branch\". That only\nfetches that single branch and stores it in FETCH_HEAD. The merge part\nthen merges what is in FETCH_HEAD into your current branch.\n\n> On the other hand, if I try to do this with a  fetch/merge, I get:\n>\n> rene@7ixe4:~/src/linux/7ixe4$ git checkout tmp1\n> Switched to branch \"tmp1\"\n> rene@7ixe4:~/src/linux/7ixe4$ git fetch tiwai\n> From git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6\n>  ! [rejected]        devel      -> tiwai/devel  (non fast forward)\n>  ! [rejected]        dma-fix    -> tiwai/dma-fix  (non fast forward)\n>  ! [rejected]        master     -> tiwai/master  (non fast forward)\n\nThe rejected branches had their history rewritten since your last fetch.\nGit rejects to update your remote tracking branches in that case. The\nhistory rewriting might have been an accident, or it might have been\nintentional. Only the owner of that repo is able to tell that.\n\nYou can use -f to force the updates.\n\n> rene@7ixe4:~/src/linux/7ixe4$ git merge tiwai/devel\n> Auto-merged sound/pci/ac97/ac97_patch.c\n> Auto-merged sound/pci/emu10k1/emu10k1_main.c\n> Auto-merged sound/pci/hda/patch_analog.c\n> Auto-merged sound/pci/hda/patch_realtek.c\n> CONFLICT (content): Merge conflict in sound/pci/hda/patch_realtek.c\n> Auto-merged sound/pci/hda/patch_sigmatel.c\n> Automatic merge failed; fix conflicts and then commit the result.\n>\n> and me no happy...\n>\n> It probably has something to do with that \" ! [rejected]\" but what is  \n> that about? Is the repo bad? (and if so, I suspect owner will want to  \n> know how to avoid it in the future).\n>\n> And if it is bad, should I be seeing something with the pull method  \n> also? Moreover... can I now trust my tmp0 branch?\n\nYour fetch/merge approach was different from what your pull approach\ndid. tiwai/devel did not get updated by the fetch, which means that you\ntried to merge the old state of that branch and that caused some\nconflicts. OTOH the pull did fetch the latest state from the remote repo\nand merged that cleanly.\n\nYour fetch/merge approach was more like \"git pull\" without any\narguments, but with the current branch setup to track tiwai/devel. In\nthat case, pull really does a \"git fetch tiwai\", and it should fail in\nthe same way.\n\nBjörn\n"},{"id":"84176","messageId":"48846BC2.4090407@keyaccess.nl","threadId":"14562","inReplyTo":"20080721102320.GA19776@atjola.homenet","subject":"Re: git pull versus fetch/merge","fromName":"Rene Herman","fromEmail":"rene.herman@keyaccess.nl","sentAt":"2008-07-21T10:58:10Z","receivedAt":"2008-07-21T10:58:10Z","isPatch":false,"sender":{"key":"rene.herman@keyaccess.nl","avatar":null},"body":"On 21-07-08 12:23, Björn Steinbrink wrote:\n\n> Your fetch/merge approach was different from what your pull approach \n> did. tiwai/devel did not get updated by the fetch, which means that\n> you tried to merge the old state of that branch and that caused some \n> conflicts. OTOH the pull did fetch the latest state from the remote\n> repo and merged that cleanly.\n> \n> Your fetch/merge approach was more like \"git pull\" without any \n> arguments, but with the current branch setup to track tiwai/devel. In\n> that case, pull really does a \"git fetch tiwai\", and it should fail\n> in the same way.\n\nThank you. Also due to a reply on the ALSA list by Mark brown I now get \nthis. Yes, the remote was rebased while I had it setup as a remote here \nit seems; only recently have it under this name, so I didn't think that \nwas the case. After a \"git remote rm tiwai, git remote add tiwai <url>\" \nthings work fine again as it fetched a completely new branch.\n\nHurray for rebasing public trees. This specific branch should be rebased \nonly at every kernel release so I guess it's okay. I guess I can just do\nthe git pull always, or the fetch every time and let the reject warn me \nthat it was rebased after which I'll do the remote rm/add thing again.\n\nMany thanks for the concrete description of what goes on. Made it obvious.\n\nRene.\n"},{"id":"84180","messageId":"20080721110900.GA8550@sigill.intra.peff.net","threadId":"14562","inReplyTo":"48846BC2.4090407@keyaccess.nl","subject":"Re: git pull versus fetch/merge","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-07-21T11:09:00Z","receivedAt":"2008-07-21T11:09:00Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jul 21, 2008 at 12:58:10PM +0200, Rene Herman wrote:\n\n> Thank you. Also due to a reply on the ALSA list by Mark brown I now get  \n> this. Yes, the remote was rebased while I had it setup as a remote here  \n> it seems; only recently have it under this name, so I didn't think that  \n> was the case. After a \"git remote rm tiwai, git remote add tiwai <url>\"  \n> things work fine again as it fetched a completely new branch.\n\nNot that adding the remote with \"git remote add\" will add a fetchspec\nline like this:\n\n[remote \"tiwai\"]\n  fetch = +refs/heads/*:+refs/remotes/tiwai/*\n\nwhere the '+' means to force fetching rewound branches instead of\nrejecting them (this is safe, since you are just overwriting tracking\nbranches, not your local work). So this should not come up again;\npresumably your previous remote configuration was set up differently.\n\n-Peff\n"},{"id":"84181","messageId":"20080721110957.GB8550@sigill.intra.peff.net","threadId":"14562","inReplyTo":"20080721110900.GA8550@sigill.intra.peff.net","subject":"Re: git pull versus fetch/merge","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-07-21T11:09:57Z","receivedAt":"2008-07-21T11:09:57Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jul 21, 2008 at 07:09:00AM -0400, Jeff King wrote:\n\n> Not that adding the remote with \"git remote add\" will add a fetchspec\n  ^^^\n\nErr, that should be \"note\", of course. I am having a real problem typing\ntoday.\n\n-Peff\n"},{"id":"84184","messageId":"48847344.5060908@keyaccess.nl","threadId":"14562","inReplyTo":"20080721110900.GA8550@sigill.intra.peff.net","subject":"Re: git pull versus fetch/merge","fromName":"Rene Herman","fromEmail":"rene.herman@keyaccess.nl","sentAt":"2008-07-21T11:30:12Z","receivedAt":"2008-07-21T11:30:12Z","isPatch":false,"sender":{"key":"rene.herman@keyaccess.nl","avatar":null},"body":"On 21-07-08 13:09, Jeff King wrote:\n\n> On Mon, Jul 21, 2008 at 12:58:10PM +0200, Rene Herman wrote:\n> \n>> Thank you. Also due to a reply on the ALSA list by Mark brown I now get  \n>> this. Yes, the remote was rebased while I had it setup as a remote here  \n>> it seems; only recently have it under this name, so I didn't think that  \n>> was the case. After a \"git remote rm tiwai, git remote add tiwai <url>\"  \n>> things work fine again as it fetched a completely new branch.\n> \n> Note that adding the remote with \"git remote add\" will add a fetchspec\n> line like this:\n> \n> [remote \"tiwai\"]\n>   fetch = +refs/heads/*:+refs/remotes/tiwai/*\n> \n> where the '+' means to force fetching rewound branches instead of\n> rejecting them (this is safe, since you are just overwriting tracking\n> branches, not your local work).\n\nNot here...\n\nrene@7ixe4:~/src/linux/7ixe4$ git remote add tmp \ngit://git.alsa-project.org/alsa-kernel.git\nrene@7ixe4:~/src/linux/7ixe4$ tail -3 .git/config \n\n[remote \"tmp\"]\n\turl = git://git.alsa-project.org/alsa-kernel.git\n\tfetch = refs/heads/*:refs/remotes/tmp/*\nrene@7ixe4:~/src/linux/7ixe4$ git --version\ngit version 1.5.5\n\n> So this should not come up again; presumably your previous remote\n> configuration was set up differently.\n\nMust be something new or configuration dependent I presume? It's not an \noption to git-remote it seems (but yes, thanks, I guess I'll add the +s \n-- a failed merge is warning enough that I need to rebuild whatever \nbranch I'm pulling it into I guess).\n\nRene.\n"},{"id":"84186","messageId":"20080721113352.GA21009@atjola.homenet","threadId":"14562","inReplyTo":"48847344.5060908@keyaccess.nl","subject":"Re: git pull versus fetch/merge","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-07-21T11:33:52Z","receivedAt":"2008-07-21T11:33:52Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.07.21 13:30:12 +0200, Rene Herman wrote:\n> On 21-07-08 13:09, Jeff King wrote:\n>\n>> On Mon, Jul 21, 2008 at 12:58:10PM +0200, Rene Herman wrote:\n>>\n>>> Thank you. Also due to a reply on the ALSA list by Mark brown I now \n>>> get  this. Yes, the remote was rebased while I had it setup as a \n>>> remote here  it seems; only recently have it under this name, so I \n>>> didn't think that  was the case. After a \"git remote rm tiwai, git \n>>> remote add tiwai <url>\"  things work fine again as it fetched a \n>>> completely new branch.\n>>\n>> Note that adding the remote with \"git remote add\" will add a fetchspec\n>> line like this:\n>>\n>> [remote \"tiwai\"]\n>>   fetch = +refs/heads/*:+refs/remotes/tiwai/*\n>>\n>> where the '+' means to force fetching rewound branches instead of\n>> rejecting them (this is safe, since you are just overwriting tracking\n>> branches, not your local work).\n>\n> Not here...\n>\n> rene@7ixe4:~/src/linux/7ixe4$ git remote add tmp  \n> git://git.alsa-project.org/alsa-kernel.git\n> rene@7ixe4:~/src/linux/7ixe4$ tail -3 .git/config \n>\n> [remote \"tmp\"]\n> \turl = git://git.alsa-project.org/alsa-kernel.git\n> \tfetch = refs/heads/*:refs/remotes/tmp/*\n> rene@7ixe4:~/src/linux/7ixe4$ git --version\n> git version 1.5.5\n\nBroken in 1.5.5 and 1.5.5.1, Jeff's fix went into 1.5.5.2. Bad luck ;-)\n\nBjörn\n"},{"id":"84187","messageId":"48847579.5080006@keyaccess.nl","threadId":"14562","inReplyTo":"20080721113352.GA21009@atjola.homenet","subject":"Re: git pull versus fetch/merge","fromName":"Rene Herman","fromEmail":"rene.herman@keyaccess.nl","sentAt":"2008-07-21T11:39:37Z","receivedAt":"2008-07-21T11:39:37Z","isPatch":false,"sender":{"key":"rene.herman@keyaccess.nl","avatar":null},"body":"On 21-07-08 13:33, Björn Steinbrink wrote:\n\n>> rene@7ixe4:~/src/linux/7ixe4$ git --version\n>> git version 1.5.5\n> \n> Broken in 1.5.5 and 1.5.5.1, Jeff's fix went into 1.5.5.2. Bad luck ;-)\n\nSheesh. Thanks :-)\n\nRene.\n"}]}