git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Jason Garber <jgarber@ionzoft.com>
Cc: git@vger.kernel.org
Subject: Re: git push [rejected] question
Date: Mon, 18 Feb 2008 23:33:53 -0500	[thread overview]
Message-ID: <20080219043353.GA23239@sigill.intra.peff.net> (raw)
In-Reply-To: <E7DE807861E8474E8AC3DC7AC2C75EE50542F2F1@34093-EVS2C1.exchange.rackspace.com>

On Mon, Feb 18, 2008 at 04:15:01PM -0600, Jason Garber wrote:

> One of our users had this come up today.  He (on a different branch)
> did a push (successfully) earlier today.  Upon pushing some more
> changes this afternoon in the "Task/4919..." branch, the following
> message was received:

I think the user is missing one fundamental aspect of pushing: the
behavior of "git push" without any refspecs specified is to push all
matching refs (i.e., if you have branch refs/heads/Issue/Default and so
does the remote, then it will attempt to push). So no matter what branch
he is on when doing the push, it tries to push many such branches.

If you want to push just the current branch, try:

  git push origin HEAD

> [caleb@neon VOS4]$ git push
> Enter passphrase for key '/home/caleb/.ssh/id_rsa':
> To ssh://git@code.izrm.com/~/WhiteBoot4/VOS4-NEW
>  ! [rejected]        Issue/Default -> Issue/Default (non-fast forward)
>  ! [rejected]        Issue/Task_4831_MUP_Survey_Layout -> Issue/Task_4831_MUP_Survey_Layout (non-fast forward)
>  ! [rejected]        Task/4872-MUP-APlan-promotion -> Task/4872-MUP-APlan-promotion (non-fast forward)
>  <snip>
> error: failed to push to 'ssh://git@code.izrm.com/~/WhiteBoot4/VOS4-NEW'

These branches are rejected because he has local branches of the same
name that are _behind_ where the remote is. In other words, pushing
would roll back history, and therefore these pushes are rejected without
the '-f' option to force.

These branches get in this state through something like:

  # check out a local branch to match an upstream branch
  git checkout -b Issue/Default origin/Issue/Default
  # now hack on it or whatever
  hack hack hack
  build build build
  # and we're finished, so let's go back to another branch
  git checkout Task/4919...
  # time passes, and somebody else pushes changes to Issue/Default

And now at this point the user's Issue/Default is behind the remote's.
Pushing would roll back history, and so is rejected.

> However the branch in question was pushed successfully (despite the error message).
> 
> * Task/4919-MUP-Agent-ID-promotion         7e80ca6
>   origin/Task/4919-MUP-Agent-ID-promotion  7e80ca6

Yes, presumably that was in your <snip> section above. The "error:"
message is reported if pushing _any_ branch fails or is rejected. If you
are interested in pushing only the one branch, then you need to say so
explicitly.

-Peff

  reply	other threads:[~2008-02-19  4:34 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-18 22:15 git push [rejected] question Jason Garber
2008-02-19  4:33 ` Jeff King [this message]
2008-02-19 13:09   ` Jay Soffian
2008-02-19 15:08     ` Jeff King
2008-02-19 15:18       ` Jay Soffian
2008-02-19 15:25         ` Jeff King
2008-02-19 15:59           ` Johannes Schindelin
2008-02-19 16:14           ` [PATCH(TIC)] push: annoy all users by deprecating the default semantics Johannes Schindelin
2008-02-19 16:21             ` Jason Garber
2008-02-19 16:41               ` Johannes Schindelin
2008-02-19 16:37             ` Jeff King
2008-02-19 16:54               ` Johannes Schindelin
2008-02-19 17:05                 ` Jeff King
2008-02-20  1:03                   ` Govind Salinas
2008-02-20  1:10                     ` Junio C Hamano
2008-02-20  1:21                       ` Govind Salinas
2008-02-20  3:15                         ` Junio C Hamano
2008-02-19 18:40               ` Jay Soffian
     [not found]     ` <E7DE807861E8474E8AC3DC7AC2C75EE50542F62D@34093-EVS2C1.exchange.rackspace.com>
2008-02-19 15:21       ` git push [rejected] question Jeff King

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=20080219043353.GA23239@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=jgarber@ionzoft.com \
    /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).