I am not able to push to remote repo
Asked by Shyam:

I am not able to push to remote repo. Please help

I am seeing below error

kumar@DESKTOP-24PTARK MINGW64 /d/gitrails/check (master)  
$ git push  
fatal: The current branch master has no upstream branch.  
To push the current branch and set the remote as upstream, use

git push --set-upstream origin master

<br />

kumar@DESKTOP-24PTARK MINGW64 /d/gitrails/check (master)  
$ git push --set-upstream origin master  
To <https://bitbucket.org/USERNAME/hbc.git>  
! \[rejected\] master -\> master (fetch first)  
error: **failed to push some refs to '<https://bitbucket.org/USERNAMR/hbc.git>'**   
**hint: Updates were rejected because the remote contains work that you do**   
**hint: not have locally. This is usually caused by another repository pushing**   
**hint: to the same ref. You may want to first integrate the remote changes**   
**hint: (e.g., 'git pull ...') before pushing again.**   
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

kumar@DESKTOP-24PTARK MINGW64 /d/gitrails/check (master)  
$


Answers:
author: Caroline R
body: Hi, [@Shyam](/t5/user/viewprofilepage/user-id/4756005), thank you for reaching out to Atlassian Community.

By the output you shared with us of git pull, apparently, your local main branch is not tracking the remote main branch:

    If you wish to set tracking information for this branch you can do so with:git branch --set-upstream-to=origin/<branch> master

In this case, I would suggest checking with the command **git remote -v** if your remote is named **origin** and if local and remote branches are named **master**. After confirming that, you can run:

    git branch --set-upstream-to=origin/master master

and then try to pull. You can also try to run this command:

    git pull origin master

Just to give you some context, when you clone a repo, the main branch gets cloned (usually called "master"), and then your local main branch is set to track your remote main branch. I'm not sure what happened in your repo, but it seems that somehow that connection was removed.

Please let me know how it goes and feel free to share any additional questions or concerns regarding this case.

Kind regards,   
Caroline


author: Shyam
body: Please pull the changes first by using following command:

```
git pull 
```

comments: author: Shyam
body: Hi Grabalski,

Thank you for the response.

I am getting below message when I do *git pull,*

kumar@DESKTOP-24PTARK MINGW64 /d/gitrails/check/hello-bitbucket (master)  
**$ git push**   
fatal: The current branch master has no upstream branch.  
To push the current branch and set the remote as upstream, use

git push --set-upstream origin master

<br />

kumar@DESKTOP-24PTARK MINGW64 /d/gitrails/check/hello-bitbucket (master)  
**$ git pull**   
There is no tracking information for the current branch.  
Please specify which branch you want to merge with.  
See git-pull(1) for details.

git pull \<remote\> \<branch\>

If you wish to set tracking information for this branch you can do so with:

git branch --set-upstream-to=origin/\<branch\> master

<br />

kumar@DESKTOP-24PTARK MINGW64 /d/gitrails/check/hello-bitbucket (master)


author: Shyam
body: Hi Grabalski,

Did u have a chance to look my above thread?


Tags: bitbucket-cloud

cloud