allanberry
allanberry

Reputation: 7765

reassign an existing remote repo to my local repo

So I don't get something here about Git/Bitbucket, but I'm not sure what exactly. A bit out of my depth, perhaps.

I have a project which has laid dormant for a year, and which has somehow lost its connection to Bitbucket. How do I reassign an existing remote origin to my local repo?

I did a local git commit (which worked fine), but when I did git pull in advance of a push, I got this:

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

I tried:

git branch --set-upstream-to=origin/[email protected]:<username>/<repo>.git master

...which didn't work. I got this:

error: the requested upstream branch 'origin/[email protected]:<username>/<repo>.git' does not exist
hint: 
hint: If you are planning on basing your work on an upstream
hint: branch that already exists at the remote, you may need to
hint: run "git fetch" to retrieve it.
hint: 
hint: If you are planning to push out a new local branch that
hint: will track its remote counterpart, you may want to use
hint: "git push -u" to set the upstream config as you push.

I know I have a BitBucket repo for this project (visiting BitBucket in my browser confirms this), and the project status is only one commit behind.

Thanks in advance.

Upvotes: 0

Views: 296

Answers (1)

Anshul Goyal
Anshul Goyal

Reputation: 76877

Instead of

git branch --set-upstream-to=origin/[email protected]:<username>/<repo>.git master

Try using

git branch --set-upstream-to=origin/master master

And afterwards, run a git fetch.

Upvotes: 1

Related Questions