Git remote origin already exists: Inspect, Update or Replace the Remote
After cloning someone else’s repository and adapting the code, you may see this error when trying to add your own remote:
| |
First inspect the current remotes:
| |
If you want to keep the existing origin name and only change its URL, the simplest option is:
| |
Alternatively, remove and recreate it:
Then push the current branch:
| |
Using HEAD avoids assuming that the branch is named master; modern repositories often use main or another default branch.