Change git remote origin

When you’re swapping out a placeholder wordpress site and database for an actual in-development site, you need to change the origin remote that your local folder refers to. Indeed, a good practice is to host your “reference” work on an outside repository, like github or gitlab. This means you must tell your local computer where to find this reference, the “origin” remote that it must track and push/pull to.

  • Navigate to the folder where you intend to synchronize your data.
  • If you’ve set up your installation without any placeholder website, and no origin has been set up yet, you’ll want to add an origin remote to git. That’s different from what we’re doing here, which is changing an existing origin remote: replacing the default placeholder one with the one we’re going to work on.
  • Go copy the URL of the repository that contains your reference work.
  • Type the following in your terminal (use Shift + Insert to paste what you just copied):
  • git remote set-url origin https://github.yourremoterepositoryurl

After running this command, you can check that the new origin URL is correct with :

git remote -v

It will show the origin URL to which the local folder will pull and push to/from.

Next step is either to use a git pull or git fetch.