How to remove a remote replace git repository

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

Panjeh
2 min readJul 22, 2019

1- First Solution:

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

$ 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: git remote rm 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)

I would like to introduce two packages for Laravel that I have recently developed: Laravel Pay Pocket, a modern multi-wallet package, and Laravel Failed Jobs, a UI for the Laravel Failed Jobs Table. I hope they may be of help to you.

https://github.com/HPWebdeveloper/laravel-pay-pocket
https://github.com/HPWebdeveloper/laravel-failed-jobs

--

--