1

I need a help in removing the repository that I connected to my vs code. Actually, I want to add a new repository that is a different one from the existing one.

Scenario: 'repo1' exists in the vs code. I need to add a new one i.e., 'repo2' and remove the old one 'repo1' from the vs code.

dippas
  • 58,591
  • 15
  • 114
  • 126
mrao.bhumireddi
  • 11
  • 1
  • 1
  • 2
  • 1
    you can remove folder .git for repo1. and using terminal `git init` for new repo. – klb Jun 11 '20 at 05:56
  • 2
    @klb please attention, if you delete .git you will lost all of the commits and branches, If you just wanna change the repo remote do like what I say as question below – Peyman Majidi Jun 11 '20 at 12:00
  • Does this answer your question? [How do I change the URI (URL) for a remote Git repository?](https://stackoverflow.com/questions/2432764/how-do-i-change-the-uri-url-for-a-remote-git-repository) – Itération 122442 Aug 22 '23 at 11:55

1 Answers1

1

Actually it is about your local git, and the the default remote name is 'origin' In the vscode terminal/console type this command:

git remote set-url origin new.git.url/here

so, it will update your repo address. if you want to add a new one, instead of overwriting the old one you can simply type this commands:

git remote add myorigin git@github.com:User/UserRepo.git

then when you want to push/pull/fetch you should do like this:

git push -u myorigin master

myorigin is a custom name or alias for your new repo address. you can call it whatever you like to.

Also, you can check existing remotes with:

git remote -v

Check out this answer for updating existing repo

Check out this answer for adding new repo

Happy Coding friend ❤

Peyman Majidi
  • 1,777
  • 2
  • 18
  • 31