0

I want to remove the wrong repository and replace it with the correct repository on GitHub. What do I do?

Fatal: repository "https://GitHub.com/username/alx-pre_school.git" not found
SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
  • 1
    Does this answer your question? [How to change the URI (URL) for a remote Git repository?](https://stackoverflow.com/questions/2432764/how-to-change-the-uri-url-for-a-remote-git-repository) – SwissCodeMen May 30 '21 at 21:01

2 Answers2

1

Most likely you have named your repository origin, you can check it by running

git remote -v

The output will look like

origin  https://github.com/user/your_repo.git (fetch)
origin  https://github.com/user/your_repo.git (push)

To change the remote's repository URL run

git remote set-url origin https://github.com/user/new_name.git
geobreze
  • 2,274
  • 1
  • 10
  • 15
1

You could simply execute the following command to change the URI:

  • HTTPS

    git remote set-url origin https://github.com/USERNAME/REPOSITORY.git

  • SSH

    git remote set-url origin git@github.com:USERNAME/REPOSITORY.git

Alternatively, find .git/config in the cloned folder structure, look for [remote "origin"], and edit the url = assignment.

.git/config would look similar to below,

[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = https://github.com/USERNAME/REPOSITORY.git

Verify whether its working by examining the remotes:

git remote -v
# origin  git://new.location (fetch)
# origin  git://new.location (push)

Next time you push, mention the upstream like below:

git push -u origin master

Reference: GitHub: Manage Remote repositories

Keshan Nageswaran
  • 8,060
  • 3
  • 28
  • 45