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!
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.