git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: push rejected (non-fast-forward)

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 25, 2014, 19:16 UTC
Message-ID
<xmqqsih7rsyu.fsf@gitster.dls.corp.google.com>
In-Reply-To
<C2E11014-CFE8-490E-A21A-DB42CC8E4175@gmail.com>
debugging data <debugging.data@gmail.com> writes:
Show 19 quoted lines
> $ git push origin so-much-foo
> To git@github.com:user-two/project.git
>  ! [rejected]        so-much-foo -> so-much-foo (non-fast-forward)
> error: failed to push some refs to 'git@github.com:user-two/project.git'
> hint: Updates were rejected because the tip of your current branch is behind
> hint: its remote counterpart. Integrate the remote changes (e.g.
> hint: 'git pull ...') before pushing again.
>
>
> It doesn't look like the tip is behind though:
>
>
> /project$ git log
> commit dd240b6ba15d27d074726e9b1b0e665e3507a2fd
> Author: User Two <debugging.data+user2@gmail.com>
> ...
> Date:   Mon Nov 24 22:43:08 2014 +0000
>
>     file-one.txt with contents "file one"

I do not think anybody can say "It doesn't look like the tip is behind" by looking only at the above. I am assuming that you are on your "so-much-foo" branch, but that shows only your state. You are not inspecting what is actually on the remote branch you are pushing to, so...

After the failed "git push origin so-much-foo", try "git fetch origin so-much-foo", which will make the tip of the so-much-foo branch over there temporarily available in your FETCH_HEAD. And then do something like:

    $ git show-branch FETCH_HEAD so-much-foo

and see how they have diverged. If you want to merge your work with the updated origin, you can do

    $ git merge FETCH_HEAD
after that, or follow the hint given by the failed push, i.e.
> hint: its remote counterpart. Integrate the remote changes (e.g.
> hint: 'git pull ...') before pushing again.
and do
    $ git pull origin so-much-foo

(which by the way can be done without the "git fetch origin ..." and "git show-branch ..." steps above).

Previous: debugging dataNext: debugging data
Message 2 of 3 in “push rejected (non-fast-forward)”
  1. debugging dataNov 25, 2014
  2. Junio C HamanoNov 25, 2014
  3. debugging dataNov 26, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.