简体   繁体   中英

How do I change the github repo my React app is connected to?

I was trying to add my react project to github when I accidentally spelled my username wrong in the terminal. Now whenever I try to add the project to a repository it says it cannot find the repository, the one where I spelled my username wrong. How can I change which repository my project is being pushed into? I am new to using Git and Github.

I believe you should change the remote URL of the local repo.

git remote set-url <remote_name> <remote_url>

Example:

git remote set-url origin https://git-repo/new-repository.git

More info on this can be found here

Other than that, I would recommend deleting your.git folder in the root of your project and start all over again.

You don't need to change the GitHub repository if you only made a mistake in the username.

You need to drop the wrong authorization from credential helper.

  echo "url=https://github.com" | git credential reject

Then repeat git push . And don't forget that instead of a password you should enter your personal access token .

If your app is connected to the wrong remote repo you can connect it again:

first check your remote:

git remote -v

The output will look something like this ( <shortname> <url> ), eg:

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

if that is the one with the wrong name in it you can remove that connection:

git remote rm <short-name>

Then you can add a new remote with the right spelling in it, eg:

git remote add origin <url>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM