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.
CodePudding user response:
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.
CodePudding user response:
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.
CodePudding user response:
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>
), e.g.:
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, e.g.:
git remote add origin <url>