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

How can I push code to an empty repo when I get "No such remote 'origin'" error?

I have a local project that I have been using git for version control for. I would like to put this project on Bitbucket as a remote backup. I tried following the instructions in the documentation here . However, on the second step, "Change the remote URL on your local repo", I get the following error:

fatal: No such remote 'origin'

This would lead me to believe I've copied the URL from Bitbucket wrong, but I've tried to see how and I don't see anything wrong. It is of the form

https://user@bitbucket.org/user/project.git

Has anyone else encountered this and know how to fix it, or otherwise have helpful troubleshooting advice? Thanks!

1 answer

1 accepted

1 vote
Answer accepted

I was able to figure out the solution to my own problem by reading more about the `git remote` options here . The issue is that the Bitbucket documentation tells you to use

git remote set-url <url>

whereas if you never had a remote origin for your local project you instead need to use

git remote add <url>

After doing it that way, it worked just fine, so if you run into this issue taking that approach might help you!.

 

PS: If you get

! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://user@bitbucket.org/user/project.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.

you can fix this by changing

git push -u origin --all

from the documentation to

git push -u -f origin --all

Tyler T Atlassian Team Jan 04, 2021

Nice work figuring it out!

This guide is quite helpful and goes into more detail than the documentation page: https://www.atlassian.com/git/tutorials/syncing

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,741 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