简体   繁体   English

Github多个存储库默认为旧用户名

[英]Github multiple repositories defaulting to old username

I have all the settings configured in a way that appears correct, but git is still defaulting to an incorrect username. 我以看起来正确的方式配置了所有设置,但是git仍然默认使用不正确的用户名。

I have the following set in git config: 我在git config中设置了以下内容:

alias.hist=log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=git@github.com:CORRECT_USER/project
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
user.email=ID+CORRECT_USER@users.noreply.github.com
user.name=CORRECT_USER

And it looks good. 而且看起来不错。

My /.ssh/config also has: 我的/.ssh/config也有:

Host github.com-CORRECT_USER
    HostName github.com
    User CORRECT_USER
    IdentityFile ~/.ssh/CORRECT_USER_KEY

So it looks good, too. 所以看起来也不错。

However, when I... 但是,当我...

git push 

I get: 我得到:

ERROR: Permission to  denied to TOTALLY_DIFFERENT_WRONG_USERNAME.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

What is happening that git is trying to push the right repo, with the right username, and the right ssh/config using the TOTALLY_DIFFERENT_WRONG_USERNAME? git尝试使用TOTALLY_DIFFERENT_WRONG_USERNAME使用正确的用户名和正确的ssh / config推送正确的repo是怎么回事? Where would that be set and how can I unset it? 将在哪里设置,如何取消设置?

Running: 正在运行:

$ ssh -Tv git@github.com

Will show which identity your ./ssh/config is actually connecting with in this repository. 将显示您的./ssh/config与该存储库实际连接的身份。

In this case, it looks like it ran: 在这种情况下,它看起来像是在运行:

debug1: /etc/ssh/ssh_config line 19: Applying options for *

And went with your default username, which is TOTALLY_DIFFERENT_WRONG_USERNAME. 并且使用了您的默认用户名,即TOTALLY_DIFFERENT_WRONG_USERNAME。

You can create different configs like so: 您可以像这样创建不同的配置:

# user1
Host github.com
    HostName github.com
    User user1

# user2
Host github.com
    HostName github.com
    User user2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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