Upload project to different repository

Viewed 47

I had a reactjs project which I had already uploaded to a GitHub repository, with git init, git add ., git commit and push.

I deleted this repository and created another one where now I want to make the commits in this new one.

How can I do this?

2 Answers

If you have deleted the remote one, on GitHub, and created a new empty one (still on GitHub), you can redirect your existing local commits with:

cd /path/to/existing/local/repository
git remote set-url origin https://github.com/MyAccount/MyNewRepo
git push

You can upload to as many different github/gitlab/bitbucket as you want. Bitbucket being different implementation, slightly different.

This answer focused on github.

inside local repo

git remote add origin ssh-address.

Now the repo can have maximum one "origin" as remote key. For 10 other repository

git remote add origin1 ssh-address1

git remote add origin2 ssh-address2

If you want to replace origin (i.e. the different repo as the main origin)

git remote remove origin

and add remote repo the above way.

Now. for pushing --

git push --set-upstream origin branch-name

Related