所以我现在是 github 上的“jononomo”。然而,一年前,我还是“zononomo”。我暂时放弃了软件,并在此期间购买了一台新笔记本电脑。然后我回来并在 Github 上创建了一个名为“jononomo”的新帐户,现在我正在尝试在两台笔记本电脑之间同步我的点文件。我在我的新笔记本电脑上创建了一个 git 存储库,并将其推送到 github,可以在“jononomo”帐户下查看它。然后我转到我的旧笔记本电脑并克隆了这个存储库。一切都按预期进行。
然后我对旧笔记本电脑上的点文件进行了一些更改,现在我想将这些更改推送到 github,以便我可以将它们拉到我的新笔记本电脑上。问题是当我运行命令时:
git push origin master
Run Code Online (Sandbox Code Playgroud)
我收到错误消息:
ERROR: Permission to jononomo/.dotfiles.git denied to zononomo.
Run Code Online (Sandbox Code Playgroud)
我做的第一件事就是销毁~/.ssh/id_rsa和中的旧 SSH 密钥~/.ssh/id_rsa.pub。然后我生成了新的 SSH 密钥并将新的公钥添加到我的 jononomo github 帐户中。但这并没有解决问题。如果我运行命令:
ssh -T git@github.com
Run Code Online (Sandbox Code Playgroud)
我得到回应:
Hi zononomo! You've successfully authenticated, but GitHub does not provide shell access.
Run Code Online (Sandbox Code Playgroud)
接下来,我按照此处给出的解决方案进行操作:/sf/answers/570660401/ 此人建议我创建一个~/.ssh/config包含以下内容的文件:
Host github-jononomo
User git
Hostname github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_dsa.pub
Run Code Online (Sandbox Code Playgroud)
然后他建议我运行命令:
git remote set-url origin git@github-jononomo:jononomo/.dotfiles.git
Run Code Online (Sandbox Code Playgroud)
我尝试过,但它没有解决我的问题。我仍然收到消息:
ERROR: Permission to jononomo/.dotfiles.git denied to zononomo.
Run Code Online (Sandbox Code Playgroud)
顺便说一句,我的 …
我最近遇到了一个问题,我无法将更改推送到我作为另一个用户克隆的存储库中,该存储库是我在桌面上的 git 中推送的第一个用户。
基本上是这样的
尝试将更改推送到 repo 并收到原始用户名没有权限的错误,即使这是使用第二个用户,更具体地说是 ssh 密钥克隆的。
清除 Windows 凭据管理器中的 git 条目并没有解决这个问题。
清除全局用户名和电子邮件未解决此问题
我终于能够使用以下方法推送我的更改:
GIT_SSH_COMMAND="ssh -i <path to private ssh key for second user>" git push
Run Code Online (Sandbox Code Playgroud)
我将这个帖子发布给遇到此问题的其他人,并提出一些问题,
我知道这个命令本质上是指定 ssh 连接在推送时使用的密钥,但是如果使用相同的身份文件克隆这个密钥,为什么还没有针对它?
是否有其他替代方法或更好的方法,而不是像手动更改配置值或从 Windows 凭据管理器中删除条目那样繁琐的工作?
因此,目标是将更改推送到多个 github 帐户,而无需执行诸如临时指定要使用的 ssh 密钥之类的操作。
当我使用Git时,我通常使用命令行。以便将更改推送到服务器。我使用以下命令将公钥添加到 SSH 会话:
$ eval "$(ssh-agent -s)"
ssh-add "D:/Dev/Books Spaces/Version Control with Git and GitHub/SSH/key"
Enter passphrase for D:/Dev/Books Spaces/Version Control with Git and GitHub/SSH/key:
Identity added: D:/Dev/Books Spaces/Version Control with Git and GitHub/SSH/key (me*****d@outlook.com)
Run Code Online (Sandbox Code Playgroud)
我有两个github帐户,一个用于工作,一个用于家庭。我正在做一个个人项目,无法推送到原始项目主管,因为它说我仍在登录工作帐户。
我重设了全局用户/ user.name / user.email / user.token,它仍然注册了我的工作帐户。
这可以不那么难吗?
谢谢
我看了几个答案和论坛的解决方案,但我找不到一个有效的.
我有这种情况:
~/.ssh文件夹上有两个ssh键我创建了一个~/.ssh/config包含以下内容的文件:
Host bitbucket bitbucket.org
Hostname bitbucket.org
IdentityFile ~/.ssh/id_rsa
IdentityFile ~/.ssh/other
User git
Run Code Online (Sandbox Code Playgroud)
为了理智,我还添加了第二个密钥ssh-add.运行ssh-add -l列出两个键.
使用命令行时,所有git命令都像魅力一样,具有两个存储库.但是在使用Eclipse时,我总是Invalid remote: origin在尝试使用辅助密钥克隆或从存储库中提取时出错:
Caused by: org.eclipse.jgit.errors.NoRemoteRepositoryException: git@bitbucket.org:myuser/myrepository.git: conq: repository access denied.
Run Code Online (Sandbox Code Playgroud)
我添加了二级密钥Window > Preferences > Network Connections > SSH2 > Private keys,并将GIT_SSH环境变量设置为指向我的ssh可执行文件:
$echo $GIT_SSH
/usr/bin/ssh
Run Code Online (Sandbox Code Playgroud)
我已经多次重启Eclipse甚至操作系统,没有运气.
由于我可以毫无问题地从命令行使用git,我倾向于认为Eclipse存在问题.
如何在Eclipse上使用多个Git SSH密钥?或者如何强制Eclipse在单个项目中使用我的二级密钥?
我想将项目推送到github主页.因此,我正在尝试为github创建ssh-key来管理它,但我遇到的问题是git在错误的目录中/c/Users/user82/.ssh/id_rsa)而不是在项目目录中创建了ssh-key /desktop/dogs.
我怎么能告诉Git在项目目录中创建ssh-key /desktop/dogs而不是在这个目录中c/Users/user82呢?
user82@User MINGW64 ~/desktop/dogs (master)
$ ssh-keygen -t rsa -C "example@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/user82/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/user82/.ssh/id_rsa.
Your public key has been saved in /c/Users/user82/.ssh/id_rsa.pub.
Run Code Online (Sandbox Code Playgroud)