Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

I am not able to push to remote repo

Shyam February 16, 2022

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


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)
$

2 answers

2 accepted

0 votes
Answer accepted
Caroline R
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 1, 2022

Hi, @Shyam, 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

0 votes
Answer accepted
Deleted user February 16, 2022

Please pull the changes first by using following command:

git pull 

 

Shyam February 16, 2022

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


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


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

Shyam February 17, 2022

Hi Grabalski,

Did u have a chance to look my above thread?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events