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

Re: bug report: git push fails in worktree

From
Ttionis <out@tionis.dev>
Date
Dec 6, 2022, 11:23 UTC
Message-ID
<COUP3909LNS6.YZG9S8YIV3SQ@tempest>
In-Reply-To
<xmqqr0xdnw88.fsf@gitster.g>

Sorry, you're right I totally forgot some steps. I tried to reproduce the error in a Docker Container using the Dockerfile below:

FROM alpine:latest RUN apk add git RUN git clone https://tasadar.net/tionis/test.git /root/test WORKDIR /root/test RUN git remote add other-test https://tasadar.net/tionis/other-test.git RUN git fetch other-test main:other-test RUN git branch --set-upstream-to=other-test/main other-test RUN git worktree add /root/other-test other-test WORKDIR /root/other-test RUN touch this-is-a-test-file RUN git config --global user.email "person@example.com" RUN git config --global user.name "Name" RUN git add . RUN git commit -m "commit this-is-a-test-file" CMD ["sh"]

This time git showed me following error message when trying to push:

fatal: The upstream branch of your current branch does not match the name of your current branch. To push to the upstream branch on the remote, use

    git push other-test HEAD:main
To push to the branch of the same name on the remote, use
    git push other-test HEAD
To choose either option permanently, see push.default in 'git help config'.

Following this reference I could resolve my issue by changing the config using: git config push.default upstream

I'm sorry to have wasted your time with this and wish you a nice day.
Previous: Junio C Hamano
Message 3 of 3 in “bug report: git push fails in worktree”
  1. tionisDec 6, 2022
  2. Junio C HamanoDec 6, 2022
  3. tionisDec 6, 2022

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.