Git pushing to remote GitHub repository as wrong user

后端 未结 15 845
别跟我提以往
别跟我提以往 2020-11-30 17:49

I have a work GitHub account and a personal one. First I used the personal one for test projects, then I moved on and did a repository with the other account on the same com

15条回答
  •  忘掉有多难
    2020-11-30 18:05

    Never had any problems with git till at work they recently connected our macbooks to Active Directory & added a few admin accounts to my machine. However, after that git would work fine till i locked my screen and came back. Then I would get a vague error similar to

    No user exists for uid 1927040837
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    

    I only have one ssh key on this particular machine for my user and am using zsh in my term. The user email and name were correct so that wasn't the issue. Ergo, restarting after every time i lock my machine is futile. The solution for me was to edit my .zshrc file and uncomment the line that exports the ssh-key (which i've never had to do before and have been using zsh for years).

    The line should look something like this:

    # ssh
    export SSH_KEY_PATH="~/.ssh/"
    

    Once you do this just run a reset in terminal and everything works fine.

    I hope this helps someone else.

提交回复
热议问题