Did*_*ver 5 github git-push git-remote
在 Visual Studio 代码中
我为此花费了更多时间,我正在尝试将来自第一个帐户 github 的已删除项目推送到 新的另一个帐户中的现有存储库中,但我收到如下错误:
$ git push -u origin main
remote: Permission to username/project_name.git denied to first_account_username.
fatal: unable to access 'https://github.com/user_name/project_name.git/': The requested URL returned error: 403
Run Code Online (Sandbox Code Playgroud)
我尝试使用这些命令行将现有存储库推送到新帐户中,请让我知道我错过了什么?
git remote add origin https://github.com/user_name/project_name.git
git branch -M main
git push -u origin main
Run Code Online (Sandbox Code Playgroud)
car*_*ich 11
Git 显然会尝试使用您的旧用户名将代码推送到您的新存储库。将新用户名显式添加到 URL:
git remote set-url origin https://user_name@github.com/user_name/project_name.git
Run Code Online (Sandbox Code Playgroud)
或者使用SSH 语法:
git remote set-url origin user_name@github.com:user_name/project_name.git
Run Code Online (Sandbox Code Playgroud)