Skip to content

Instantly share code, notes, and snippets.

@schneefisch
Last active October 14, 2022 11:22
Show Gist options
  • Save schneefisch/60387bece8d70194f1828f227151e8b0 to your computer and use it in GitHub Desktop.
Save schneefisch/60387bece8d70194f1828f227151e8b0 to your computer and use it in GitHub Desktop.
Set a new remote URI for a git repo

Directly Set a Remote-URL if it does not yet have one

this git-command changes an existing remote repository URL

git remote set-url <https://github.com/USERNAME/REPO.git>

Migrate to a new Repository

If you want to move an existing git repo to a new remote location. First, checkout the required repo with all the branches you want to migrate

git clone <repository>
git checkout <branch1>
git checkout <branch2>

Remove existing origin

git remote remove origin

Show that there is no origin:

git remote -v

Add the new remote

git remote add origin <yourrepo>

Push all branches to the new repository

git checkout master
git push origin master
git checkout <branch1>
git push origin <branch1>
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment