{"thread":{"id":"29353","subject":"clone bug","startedAt":"2012-01-12T13:43:50Z","lastAt":"2012-01-12T14:36:46Z","messageCount":3,"participants":["Alexey Kuznetsov","Thomas Rast","Andreas Schwab"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"182430","messageId":"CAO1Zr+pSLwRbsEZ_0LCeE2qLn+S=iMKVcMjqtYrmiBoQmjac_A@mail.gmail.com","threadId":"29353","inReplyTo":null,"subject":"clone bug","fromName":"Alexey Kuznetsov","fromEmail":"kuznetsov.alexey@gmail.com","sentAt":"2012-01-12T13:43:50Z","receivedAt":"2012-01-12T13:43:50Z","isPatch":false,"sender":{"key":"kuznetsov.alexey@gmail.com","avatar":null},"body":"Hello!\n\nSeems like I found a bug in the clone / push logic. I'm trying to\nclone remote branch master into local branch called common and unable\nto push back common to master. Git trying to push local master from\ndifferent origin to common/master instead.\n\nHere is a simple example:\n\n# mkdir 123\n# git init\n# > 123\n# git add .\n# git commit -m \"initial\"\n# git branch\naxet-laptop:123 axet$ git branch\n* master\n# git remote add common https://github.com/axet/common-bin.git\n# git fetch common\nFrom https://github.com/axet/common-bin\n * [new branch]      master     -> common/master\n\n?? already strange master (local) to the remote common/master\n\n# axet-laptop:123 axet$ git checkout -b common common/master\nBranch common set up to track remote branch master from common.\nSwitched to a new branch 'common'\n\n# axet-laptop:123 axet$ git branch\n* common\n  master\naxet-laptop:123 axet$\n\n# cat .git/config\n[...]\n\n[branch \"common\"]\n\tremote = common\n\tmerge = refs/heads/master\n\n?? correct\n\naxet-laptop:123 axet$ git pull\nAlready up-to-date.\naxet-laptop:123 axet$ git push\nTo https://github.com/axet/common-bin.git\n ! [rejected]        master -> master (non-fast-forward)\nerror: failed to push some refs to 'https://github.com/axet/common-bin.git'\nTo prevent you from losing history, non-fast-forward updates were rejected\nMerge the remote changes (e.g. 'git pull') before pushing again.  See the\n'Note about fast-forwards' section of 'git push --help' for details.\naxet-laptop:123 axet$\n\n\nit tries to push local master to remote common/master which is not correct.\n\n-- AK\n"},{"id":"182431","messageId":"87aa5tng9l.fsf@thomas.inf.ethz.ch","threadId":"29353","inReplyTo":"CAO1Zr+pSLwRbsEZ_0LCeE2qLn+S=iMKVcMjqtYrmiBoQmjac_A@mail.gmail.com","subject":"Re: clone bug","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2012-01-12T14:32:06Z","receivedAt":"2012-01-12T14:32:06Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Alexey Kuznetsov <kuznetsov.alexey@gmail.com> writes:\n>\n> [branch \"common\"]\n> \tremote = common\n> \tmerge = refs/heads/master\n>\n> ?? correct\n>\n> axet-laptop:123 axet$ git pull\n> Already up-to-date.\n> axet-laptop:123 axet$ git push\n> To https://github.com/axet/common-bin.git\n>  ! [rejected]        master -> master (non-fast-forward)\n> error: failed to push some refs to 'https://github.com/axet/common-bin.git'\n> To prevent you from losing history, non-fast-forward updates were rejected\n> Merge the remote changes (e.g. 'git pull') before pushing again.  See the\n> 'Note about fast-forwards' section of 'git push --help' for details.\n> axet-laptop:123 axet$\n>\n>\n> it tries to push local master to remote common/master which is not correct.\n\nThis is controlled by the 'push.default' variable, the docs for which\nare as follows:\n\n  push.default::\n  \tDefines the action git push should take if no refspec is given\n  \ton the command line, no refspec is configured in the remote, and\n  \tno refspec is implied by any of the options given on the command\n  \tline. Possible values are:\n  +\n  * `nothing` - do not push anything.\n  * `matching` - push all matching branches.\n    All branches having the same name in both ends are considered to be\n    matching. This is the default.\n  * `upstream` - push the current branch to its upstream branch.\n  * `tracking` - deprecated synonym for `upstream`.\n  * `current` - push the current branch to a branch of the same name.\n\nThe default of 'matching' pushes X to remotename/X, which is what you\nare seeing.  You can either set it to 'upstream' or specify the\ntarget explicitly, as in\n\n  git push common common:master\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"182432","messageId":"m28vldj8ch.fsf@igel.home","threadId":"29353","inReplyTo":"CAO1Zr+pSLwRbsEZ_0LCeE2qLn+S=iMKVcMjqtYrmiBoQmjac_A@mail.gmail.com","subject":"Re: clone bug","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-01-12T14:36:46Z","receivedAt":"2012-01-12T14:36:46Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Alexey Kuznetsov <kuznetsov.alexey@gmail.com> writes:\n\n> axet-laptop:123 axet$ git branch\n> * master\n> # git remote add common https://github.com/axet/common-bin.git\n> # git fetch common\n> From https://github.com/axet/common-bin\n>  * [new branch]      master     -> common/master\n>\n> ?? already strange master (local) to the remote common/master\n\nThe message means: the remote ref 'refs/heads/master' is stored locally\nin 'refs/remotes/common/master'.\n\n> axet-laptop:123 axet$ git push\n> To https://github.com/axet/common-bin.git\n>  ! [rejected]        master -> master (non-fast-forward)\n\n\"git push\" is the same as \"git push common\" ('common' is the current\nbranch's remote).  Since branch.master.push is not defined this then\nuses the push.default config option to determine the action.  The\ndefault is 'matching', which means that local branch names are matched\nagainst remote branch names.  Local branch master matches remote branch\nmaster.  Note that this disregards the setting for\nbranch.master.upstream.  If you do not want that you should set\npush.default to 'upstream'.\n\nSee the examples in git-push(1) for more details.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"}]}