Subject: Re: clone bug

From: Thomas Rast <[email-masked]>
Date: Thu, 12 Jan 2012 15:32:06 +0100

Alexey Kuznetsov <[email-masked]> writes:
>
> [branch "common"]
> 	remote = common
> 	merge = refs/heads/master
>
> ?? correct
>
> axet-laptop:123 axet$ git pull
> Already up-to-date.
> axet-laptop:123 axet$ git push
> To https://github.com/axet/common-bin.git
>  ! [rejected]        master -> master (non-fast-forward)
> error: failed to push some refs to 'https://github.com/axet/common-bin.git'
> To prevent you from losing history, non-fast-forward updates were rejected
> Merge the remote changes (e.g. 'git pull') before pushing again.  See the
> 'Note about fast-forwards' section of 'git push --help' for details.
> axet-laptop:123 axet$
>
>
> it tries to push local master to remote common/master which is not correct.

This is controlled by the 'push.default' variable, the docs for which
are as follows:

  push.default::
  	Defines the action git push should take if no refspec is given
  	on the command line, no refspec is configured in the remote, and
  	no refspec is implied by any of the options given on the command
  	line. Possible values are:
  +
  * `nothing` - do not push anything.
  * `matching` - push all matching branches.
    All branches having the same name in both ends are considered to be
    matching. This is the default.
  * `upstream` - push the current branch to its upstream branch.
  * `tracking` - deprecated synonym for `upstream`.
  * `current` - push the current branch to a branch of the same name.

The default of 'matching' pushes X to remotename/X, which is what you
are seeing.  You can either set it to 'upstream' or specify the
target explicitly, as in

  git push common common:master

-- 
Thomas Rast
trast@{inf,student}.ethz.ch