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

Re: branch.<name>.pushremote not working with push.default simple or upstream

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Jun 7, 2013, 14:11 UTC
Message-ID
<CALkWK0miONv_O67SHcfJoXq1x7xPvKu6uefg+TiPGbF-1WJ-bg@mail.gmail.com>
In-Reply-To
<20130607124146.GF28668@sociomantic.com>
[+CC: jc, jk]
Leandro Lucarella wrote:
Show 8 quoted lines
> I changed branch.master.remote to upstream and set
> branch.master.pushremote to origin, but when I do I git push I get an
> error:
>
> $ git push --dry-run --verbose
> fatal: You are pushing to remote 'origin', which is not the upstream of
> your current branch 'master', without telling me what to push
> to update which remote branch.

Yes, this is a defect: both remote.pushdefault and branch.<name>.pushremote suffer from it.

Let me explain what's happening. The error is triggered off in setup_push_upstream() in builtin/push.c (which both simple and upstream use). It's exactly the same error that will be reported if you do the following without a branch.master.pushremote or remote.pushdefault configured:

  $ git push origin --dry-run --verbose
  fatal: You are pushing to remote 'origin', which is not the upstream of
  your current branch 'master', without telling me what to push
  to update which remote branch.

You should therefore be able to infer that remote.pushdefault/ branch.<name>.pushremote is simply saving you from remembering/ typing out that "origin" on the command-line. The error precisely describes the problem. To understand what this "upstream" the error is talking about, see:

   $ git rev-parse --symbolic-full-name @{u}
   refs/remotes/upstream/master

So, if you are pushing to upstream, the push knows what to do: push to the refspec <branch>:<branch>@{u} (see builtin/push.c:148). If you're pushing to origin, it has no idea _what_ to push, and hence errors out. By design, upstream/ simple assume that you push to the same place that you pull from: the description clearly says that it is intended to make the push and pull symmetric.

Finally, the reason remote.pushdefault/ branch.<name>.pushremote works in the other modes is simple: in matching and current, the push refspec is not dependent on the current branch's upstream. In matching, the refspec it is the constant ":", and in current, it is the constant "HEAD" (will subtly change with rr/push-head).

I think the correct fix is to change the semantics of upstream/simple to dictate a refspec independent of remote. So, if:

1. branch.master.merge is configured to refs/heads/rr/master
2. branch.master.remote is configured to origin
3. remote.pushdefault is configured to ram
4. push.default is configured to upstream

Then, the a push should push the refspec master:rr/master to the remote ram. Let's see what the others have to say before proceeding.

Thank you for reporting this problem. It is indeed very serious, especially since simple is going to be default in Git 2.0.

Previous: Leandro LucarellaNext: Junio C Hamano
Message 2 of 9 in “branch.<name>.pushremote not working with push.default simple or upstream”
  1. Leandro LucarellaJun 7, 2013
  2. Ramkumar RamachandraJun 7, 2013
  3. Junio C HamanoJun 7, 2013
  4. Leandro LucarellaJun 7, 2013
  5. Ramkumar RamachandraJun 7, 2013
  6. Leandro LucarellaJun 7, 2013
  7. Ramkumar RamachandraJun 7, 2013
  8. Ramkumar RamachandraJun 7, 2013
  9. Junio C HamanoJun 7, 2013

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.