Git push to different remote - Git push existing repo to a new and different remote repo server?

299    Asked by Aashishchaursiya in Devops , Asked on Jul 1, 2021

Say I have a repository on git.hosted.org and I want to clone this into my account at github to have my own playground aside from the more "official" repo on hosted. What would be the steps to initially copy that over? Within github, there is this nice "fork" button, but I can't use this for obvious reasons.

And how would I track changes in the hosted repo into the github one?

Answered by P.UdayKumar

To solve git push to different remote, you need to copy the repo to your git-hub and work on it for that follow the steps:

Create a new repository in your github

Then clone the repository which you need to work on from your hosted.org to the local machine

Then rename the repo with upstream using:

  git remote rename origin upstream

Then add your repository url to your remote using:

  git remote add origin 

Then push the changes to your remote repo using:

  git push origin master

From the above steps, you can copy repo to your github.

To get updated and to pull the changes you can do:

  git pull upstream master && git push origin master

This will pull the changes and keep you updated with your official repo.



Your Answer

Interviews

Parent Categories