Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

duckmayr
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 26, 2020

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
duckmayr
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 26, 2020

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
Atlassian Team members are employees working across the company in a wide variety of roles.
January 4, 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
AUG Leaders

Atlassian Community Events