I have local git branch <BRANCH_NAME>
that has no reference to upstream origin. I have made some changes to local branch and committed the same locally. I am now trying to push to remote origin.
- When I tried:
git push --set-upstream origin <BRANCH_NAME>
it throws the error :
error:src refsprc <LOCAL_BRANHC_NAME> does not match any
error: failed to push some refs to '<REMOTE_URL>
- When i tried
git push --set-upstream origin **HEAD:**<BRANCH_NAME>
it succeeded
The difference between the commands is the prefixing of HEAD: to the "BRANCH_NAME". So my question is :
- What's difference between pushing with/without the prefix "HEAD" ?
- Would be helpful if I can get pictorial representation of what's happening behind the git commands for my better understanding.
- Let me know if more information is required from my end for clarification.
NOTE:
- I do understand what is HEAD. It points to the latest commit of the current branch.
- I did try the
cat .git/HEAD
and the output wasref: refs/heads/<BRANCH_NAME>
- which is the correct one. - I noted in some answers of stackoverflow, it was mentioned to do
git commit
. I had tried the commit approach as well and faced the same error.
Thanks in advance