Re: git push [rejected] question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxx/~/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@xxxxxxxxxxxxx/~/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
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux