Re: bug report: git push fails in worktree
- From
- tionis <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.