Skip to content

Instantly share code, notes, and snippets.

@pdbartsch
Last active May 11, 2018 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pdbartsch/f3981076b8c817fb8add46a66e30d514 to your computer and use it in GitHub Desktop.
Save pdbartsch/f3981076b8c817fb8add46a66e30d514 to your computer and use it in GitHub Desktop.
How to change remote origin

Move a repository from one web host to another

  • cd \local\repository\directory
  • show current remote and the name of the remotes: git remote -v
  • take the name of the remote you'd like to remove (e.g. origin or destination) and plug it into the next command
  • git remote rm origin will remove a remote named 'origin' but substitute your remote name here

Push the repo to new host:

  • git remote add origin https://user@example.com/userName/remoteRepoName.git
  • git push -u origin master

This method should maintain your commit history but that will depend on your chosen host

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment