There is a remote branch called "my-remote" that I had previously pushed to with no problem. As of today, I can't push and I get different errors.
First error I got was:
hint: Updates were rejected because a pushed branch tip is behind its remote hint: counterpart. If you did not intend to push that branch, you may want to hint: specify branches to push or set the 'push.default' configuration hint: variable to 'current' or 'upstream' to push only the current branch.
I did some research and ran this hoping it would solve the problem:
git config push.default tracking
after running that I ran the push again:
git push https://github.com/someurl/mybranch.git
I got the following error:
pushing to remote 'https://github.com/someurl/mybranch.git', which is not the upstream of
your current branch 'my-remote', without telling me what to push
to update which remote branch.
I have tried running this:
git push master:my-remote https://github.com/someurl/mybranch.git
but it tells me that:
fatal: remote part of refspec is not a valid name in https://github.com/someurl/mybranch.git
If you want to push your master branch on the my-remote remote branch, the correct syntax would be:
git push https://github.com/someurl/mybranch.git master:my-remote
(first: remote repo reference, the refspec, from git push
man page)
Regarding your first error message, if it really didn't tell you to merge, then a git pull --rebase
might have been needed.
Or at least a:
git config --global push.default current
(As mentioned in "Configure Git to Only Push Current Branch").
If you are in the local branch 'my-remote
' (which is the case, according to the command), you can make sure the upstream branch is set by making a:
git push -u https://github.com/someurl/mybranch.git my-remote:my-remote