How do I rename an existing Git Remote?
To change the name of an existing remote you’ll need to use the git remote rename command.
In order to change the name of your remote you will need two things.
- The current name of your remote.
- The name you want to change your remote to.
Here's an example
Let’s say that your current remote name is “origin_1”. And now you want to change the remote name to “origin_2”.
1. Confirm the name of your current remote by running the following command:
git remote -v
You should see an output like the following
origin_1 https://github.com/username/repository.git (fetch)
origin_1 https://github.com/username/repository.git (push)
2. Now that the current remote name is confirmed — you can change it by running the following command:
git remote rename origin_1 origin_2
This command tells git to rename the current remote to something different. In this example, we’re changing the remote name to “origin_2”, but you can change your remote to be anything you want.
3. Verify that your remote has changed from “beanstalk” to “origin” by running the following command:
git remote -v
You should see an output like the following
origin_2 https://github.com/username/repository.git (fetch)
origin_2 https://github.com/username/repository.git (push)