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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

I cannot publish my Code with Visual Studio repository to Bitbucket

First : I create respository on Bitbucket Cloud. 

Second : I publish the project code with visual studio with respectively URL from Bitbucket URL. 
I hit below issue: 

Error encountered while pushing branch to the remote repository: rejected Updates were rejected because the remote contains work that you do not have locally. This is usually caused by another repository pushing to the same ref. You may want to first integrate the remote changes before pushing again.

 

How to fix it, Thanks.

1 answer

1 vote

Hi Nyein Chan Aung and welcome to the community!

The error message that you get indicates that the repository in Bitbucket Cloud contains commits that you do not have locally.

This may be the case

1. either because someone pushed commits to your repository that you do not have locally

2. or because you created a repository in Bitbucket Cloud including a README or .gitignore (these are options in the Create repository page) and then did not clone the repo containing this initial commit.

In this case, your new repository in Bitbucket Cloud will contain a first commit with the README or .gitignore. If you did not clone the repository locally, but you created a new local repo and you are trying to push its code to Bitbucket, then Git will complain because your local repo doesn't have the initial commit that your remote does.

The solution in either case should be pulling any changes from the remote repo first and then you should be able to push your changes.

Please feel free to let me know how it goes and if you have any questions.

Kind regards,
Theodora

I have the same problem, the thing is the pull option is disabled in Visual Studio team explorer tab so i can't see how to do a pull before doing the push.

Hi @proskilly ,

Does the branch you are working on in Visual studio have an upstream branch configured? If not, that may be a reason why the pull option is disabled. If the upstream branch is configured but you're still having issues with the button being disabled, you may want to reach to Visual Studio support team to figure out why this occurs.

Pulling changes is a common operation when you work on a repo along with other users who push to the branch(es) you are working on, so you need to have the ability to pull changes.

If you have Git Bash installed on your machine, you can navigate to the directory of your local repo, check out the branch you are working on, set the upstream branch with the command

git branch -u <remote>/<branch>

and then you should be able to pull changes with the command

git pull

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,827 views 10 16
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you