在Git存储库中设置用户名/电子邮件和权限

时间:2016-09-27 12:55:58

标签: git github git-push git-config

我有两个Github帐户:一个用于在用户电子邮件下创建的作品:rperez@email1.com,另一个用于用户电子邮件下的个人项目:reynierpm@email2.com

我通过运行以下命令将rperez@email1.com设置为全局:

git config --global user.name "rperez"
git config --global user.email "rperez@email1.com

我需要在一个工作中的个人项目中工作,所以我克隆了存储库,现在我正在尝试设置第二个用户名作为提交到这个个人存储库的那个,所以我运行了以下命令:

git config user.name "reynierpm"
git config user.email "reynierpm@email2.com

出于某种原因,一旦我尝试将某些东西推到回购中,我就收到了这个错误:

Push failed 
Failed with error: ERROR: Permission to reypm/php55-dev.git denied to rperez. 
Could not read from remote repository.

为什么尝试将更改推送为rperez而不是reynierpm

以下是命令git config -l的输出,以防有人需要它:

$ git config -l
user.name=rperez
user.email=rperez@email1.com
gc.autodetach=false
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@github.com:reypm/php55-dev.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
user.email=reynierpm@email2.com
user.name=reynierpm

此设置有什么问题?

注意:@email1.com@email2.com是假域名,仅用于不显示真实地址。

更新#1

按照评论中的建议后,这就是~/.ssh/config中的内容:

#rperez account
Host github.com-rperez
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa

#reypm account
Host github.com-reypm
    HostName github.com
    User git  
    IdentityFile ~/.ssh/id_rsa_reynierpm

这是ls -la ~/.ssh

的输出
$ ls -la ~/.ssh/
total 32
drwx------.  2 rperez rperez 4096 Sep 27 10:21 .
drwx------. 29 rperez rperez 4096 Sep 27 09:54 ..
-rw-rw-r--   1 rperez rperez  304 Sep 27 10:30 config
-rw-------.  1 rperez rperez 3243 Sep 21 09:35 id_rsa
-rw-r--r--.  1 rperez rperez  749 Sep 21 09:35 id_rsa.pub
-rw-------.  1 rperez rperez 1675 Sep 27 09:33 id_rsa_reynierpm
-rw-r--r--.  1 rperez rperez  401 Sep 27 09:33 id_rsa_reynierpm.pub
-rw-r--r--.  1 rperez rperez 2039 Sep 26 10:19 known_hosts

最后输出git config -l

$ git config -l
user.name=rperez
user.email=rperez@email1.com
gc.autodetach=false
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@github.com:reypm/php55-dev.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
user.email=reynierpm@email2.com
user.name=Reynier Perez
remote.reypm.url=git@github.com:php55-dev.git
remote.reypm.fetch=+refs/heads/*:refs/remotes/reypm/*

将更改推送到存储库php55-dev会变成此错误:

Bad owner or permissions on /home/rperez/.ssh/config
fatal: Could not read from remote repository.

这个设置还有什么问题,它是什么?

0 个答案:

没有答案
相关问题