Changing the remote for pulling and pushing (with examples)
Use case 1: Change the upstream remote to origin
git rename-remote upstream origin
Motivation
In this use case, we want to change the remote repository used for pulling and pushing to the new “origin” repository. This is useful, for example, when you want to switch from a local development repository to an official remote repository.
Explanation
upstream
: The current name of the remote repository. In this use case, we are changing the “upstream” remote to “origin”.origin
: The new name of the remote repository we want to set.
Example Output
The output of this command will be a confirmation message that the rename operation was successful:
Changing remote uppstream to origin.
By running git remote -v
, you can now verify that the remote repository has been renamed:
origin git@github.com:user/repo.git (fetch)
origin git@github.com:user/repo.git (push)