allstar allstar - 1 month ago 5
Git Question

Push to github from local, cloned from another repo

If you have already cloned someone else's repo (rather than forking) and have been committing locally, what's the appropriate way to push that into a new remote repo on GitHub?

Answer

You can change the remote or add another one.

To change the remote

git remote set-url origin https://www.something.com/my_repo.git

To add a secondary remote as e.g. other_origin

git remote add other_origin https://www.something.com/my_repo.git

If you changed origin you can git push to the new remote. If you added another remote, you can specify during git push which remote you want to push to.

Comments