How to remove a remote replace git repository

How to remove remote origin — Change or replace new address/url for remote git repository

1- First Solution:

Suppose you have two remote git repositories, origin and destination and are going to remove

$ git remote -v
# View current remotes
> origin https://github.com/OWNER/REPOSITORY.git (fetch)
> origin https://github.com/OWNER/REPOSITORY.git (push)
> destination https://github.com/FORKER/REPOSITORY.git (fetch)
> destination https://github.com/FORKER/REPOSITORY.git (push)

$ git remote rm destination
# Remove remote
$ git remote -v
# Verify it's gone
> origin https://github.com/OWNER/REPOSITORY.git (fetch)
> origin https://github.com/OWNER/REPOSITORY.git (push)

Note: does not delete the remote repository from the server. It simply removes the remote and its references from your local repository.

To remove the origin remote git repository you can do the same:

git remote rm origin

or

git remote remove origin

2- Second Solution:

Replace new address / set new url without Removing remote git

In order not to remove the remote git repository and just replace the new address do this:

git remote set-url origin new.address.here
git remote -v
# View existing remotes
# origin https://github.com/user/repo.git (fetch)
# origin https://github.com/user/repo.git (push)

git remote set-url origin https://github.com/user/repo2.git
# Change the 'origin' remote's URL

git remote -v
# Verify new remote URL
# origin https://github.com/user/repo2.git (fetch)
# origin https://github.com/user/repo2.git (push)

Posting daily about Python, Laravel, Livewire, Nuclear Physicist PhD