We use git + Jira + Bitbucket.
Scenario:
In Jira I've created (with Create branch
option) branch XXX
.
In Bitbucket I see that the branch XXX
is appeared in the list of branches.
Make changes in the code => git commit
.
git push
gives: fatal: The current branch XXX has no upstream branch.
Question: what is the reason of this error? The branch XXX
has the upstream branch (I see this upstream branch XXX
in the Jira.)
Please note: before this error I've used git push
with NO additional arguments.
UPD0: @RadioSilence has suggested to use git branch -vv
command! I did and it helped me to see that "the local branch is not tracking the upstream". And the reason of it was (very probably) some of my previous git commands on that branch, which apparently caused disabling the tracking of the upstream by this branch. (By default after checking out any branch created with Jira the branch is tracking the upstream, hence NO additional commands/options are needed for git push
.)
As a result (solution):
I've changed the name of the branch caused the issue from XXX
to XXX_01
.
git checkout XXX
=> add changes (via git stash apply stash@{0}
) => git commit
.
git push
(with NO additional commands/options) and it worked as expected.
P.S. If anyone knows how it was possible to unintentionally disable the tracking of the upstream by the branch (created with Jira), please let us know.
As mentioned in the comments, the local branch is not tracking the upstream. This can be verified by running git branch -vv
. If the local branch has no listed upstream, then run git push -u origin XXX
.