1

I've started working on a project a few months ago. I used my private bitbucket repository for this. The only purpose was to backup my code, since I'm working alone. Now my "boss" provided another repository and want me to use it.

Do I have to remove the old repository in order to use the new one or can I use both simultaneously?

Ian Fako
  • 1,148
  • 1
  • 15
  • 34

2 Answers2

2

Yes you can have multiple remotes registered for your repository.

You have to add the new remote to your new repository. Generally main repository is named origin and the original repository (from what your forked or in your case the backup repository) is named upstream.

So what you can do:

git remote rename origin upstream # change your current 'origin' remote to 'upstream'
git remote add origin git://foo@bar.spam # add your new remote

Then, you will be able to fetch and push on both.

If your upstream is used as backup, I suggest to only push master (and eventually develop if you are using gitflow or something similar) to upstream.

So your upstream only stores your merged code when your origin stores every branches & commits.

But it depends what you need.


Here is a stackoverflow thread about origin & upstream remotes: What is the difference between origin and upstream on GitHub?

Arount
  • 9,853
  • 1
  • 30
  • 43
1

You can use the both simultaneously. You can have as many remote as you want. You just need to provide another name for the remote if the one you actually use is origin.

git remote add another-name urlto.git

You'll also need to push on both remote if you want to keep the two of them up to date.

YoannFleuryDev
  • 914
  • 1
  • 12
  • 22