Programming

자식이 터미널에서 잘못된 사용자로 푸시

procodes 2020. 8. 18. 19:22
반응형

자식이 터미널에서 잘못된 사용자로 푸시


자식과 터미널에 문제가 있습니다.

내 문제를 보여주는 갤러리가 있습니다. http://imgur.com/a/6RrEY

내 터미널에서 커밋을 푸시하면 git은 다른 사용자 이름으로 푸시한다고 말합니다. 그건 내 조직 (내 회사)의 사용자이며 커밋이 전혀 없으며 아무도 속한 것 같습니다. (갤러리 첫 번째 그림 확인)

그러나 이것은 내가 Mac 용 Github를 사용할 때 발생하지 않습니다. 피드에서 내가 직접 푸시 한 커밋을 볼 수 있습니다.

문제는 내 개인 저장소에도 영향을 미칩니다. 터미널은이 사용자와 함께 푸시하려고하기 때문에 해당 저장소에 커밋을 푸시 할 권한이 없다고 말합니다 (분명히 잘못되었습니다) : (갤러리 두 번째 그림 확인)

뭔지 맞춰봐 ? 이것은 Mac 용 Github에서도 발생하지 않습니다.

며칠 전에 컴퓨터를 새 것으로 변경했기 때문에 github의 모든 ssh 키를 재설정하고 Mac 용 Github에서 생성 한 새 키만 남겨 두었으므로 일부 유령 사용자 / ssh 키가 숨겨져 있다고 생각하지 않습니다. 어딘가에,이 hdd는 새로운 것입니다 : (갤러리 세 번째 그림 확인)

내 .gitconfig 파일은 모두 명확하며 내 자격 증명 만 있습니다. (갤러리 네 번째 그림 확인)

정말 이해가 안가요, 도움, StackOverflow, 당신은 나의 유일한 희망입니다.

(불쌍한 김프 기술과 스타 워즈 참조에 대한 나의 사과)

편집 : ssh-add -l Mac 용 github에서 만든 좋은 ssh 키만 표시되며 github 계정이 하나만 있습니다.

EDIT2 : ssh -T git@github.com 나를 좋은 사용자로 인식하십시오.

EDIT3 : 몇 가지 테스트 후 터미널이 내 사용자 이름으로 커밋을 수행하는 것처럼 보이지만 다른 사용자로 푸시하면 Mac 용 Github는 좋은 사용자 이름으로 커밋하고 푸시합니다.이 상황은 내가 가지고 / 만드는 모든 저장소에서 발생합니다 (새로운 하나).

EDIT4 : 개인 저장소 git log --pretty="%h %an %ae"에서 내 좋은 사용자 이름을 보여줍니다.

EDIT5 : 내 .NET Framework 에서 내 자격 증명을 재정의하는 환경 변수의 흔적이 없습니다 env. 좋은 자격 증명으로 이러한 변수를 설정하려고해도 문제가 지속됩니다.

EDIT6 :/.git/config 저장소 의 경로에서 사용자를 강제하면 상황이 정상적으로 작동 하지만 좋은 옵션이라고 생각하지 않습니다.http://USER@github.com/USER/REPO.git

EDIT7 : 나를 위해 커밋을 푸시 한 git 사용자를 삭제했으며 다른 오류가 발생합니다.remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/USER/REPO.git/'

최종 편집 : homebrew와 함께 git을 설치하고 입력 git config --global push.default simple 했으며 이제 사용자를 강요하지 않고도 내 자격 증명을 사용합니다. 이상하다. 도와 주신 모든 분들께 감사드립니다. 당신은 훌륭한 사람들입니다!


직장에서이 문제가 발생했습니다. Mac과 함께 제공되거나 xcode를 설치할 때 제공되는 내장 git은 키 체인에 git 자격 증명을 캐시합니다. 나를위한 해결책은 다음과 같습니다.

키 체인 액세스 시작 (cmd + 스페이스를 통해 스포트라이트 시작, 키 체인 입력, Enter 누르기)

왼쪽 상단의 키 체인 아래에서 "로그인"을 선택합니다. 왼쪽 카테고리에서 "비밀번호"를 선택합니다.

"github"라는 이름을 찾아서 삭제합니다.


github는 git의 설정이 아닌 ssh 키로 사용자를 식별합니다.

따라서 개인 계정에서 푸시를 시도 할 때 업무용 계정의 ssh 키가 키링에 없는지 확인해야하며 그 반대의 경우도 마찬가지입니다.

사용은 ssh-add -l당신의 열쇠 고리에있는 키를 결정하고, ssh-add -d <keyfile>이 작업에서 '원치 않는'SSH 키를 제거 dosent 경우, 키 링에서 키를 제거합니다 ~/.ssh/config.

출처

NB : Github는 이메일로만 커밋을 식별합니다.


다른 사용자가 제공 한 모든 훌륭한 옵션에도 불구하고이 문제를 해결하는 유일한 방법은 git을 완전히 다시 설치하고 git config --global push.default simple올바른 자격 증명을 다시 작성하도록 입력 하는 것입니다.


내 터미널이 내 사용자 이름으로 커밋을 수행하는 것처럼 보이지만 다른 사용자로 푸시합니다.

작성자 및 커미터 이름과 이메일 (GitHub에 중요)은 다음에서 파생됩니다.

git config user.name
git config user.email

그러나에서 언급 git config하고 git commit-tree, 그 값은 환경 변수로 대체 될 수있다 :

GIT_AUTHOR_NAME
GIT_AUTHOR_EMAIL
GIT_COMMITTER_NAME
GIT_COMMITTER_EMAIL

따라서 해당 변수를 다시 확인하십시오.

사용자를 .git/config저장소 에 강제로 넣으면 정상적으로 작동 하지만 좋은 옵션이라고 생각하지 않습니다.

하지만 좋은 해결책이되어야합니다.
https URL을 사용할 때 항상 올바른 사용자로 인증이 수행되도록 사용자를 지정합니다.

http://USER@github.com/USER/REPO.git

임시 솔루션을 먼저 실행 killall ssh-agent한 다음 사용해야하는 계정에 대해 생성 된 SSH 키를 추가합니다.ssh-add ~/.ssh/id_4shameer

유형 오류가 발생할 때 여러 github 계정에서 작업하는 데 도움이됩니다. ERROR: Permission to user/repo-git.git denied to username.


MAC을 사용하는 경우 키 체인 액세스 로 이동하여 git 액세스를 원하지 않는 사용자 항목을 제거하십시오.


I'm using Windows 10 and I faced the same issue today. In my case my credentials for different user were saved by Windows Credential manager. Thus deleting/unsetting git credentials with below command, git config --global --unset credential.helper

didn't help. I had to manually delete the entry in Windows by following the below way,

Start --> Control Panel ---> User Accounts ---> Manager your credentials ---> Windows Credentials

Then search for an entry like, git:https://github.com and remove it. It works fine after that.


The solution for me was to add an entry in my ~/.ssh/config file for github. I had to do this because:

  1. I had multiple github accounts with the same key (don't do this!)
  2. when you 'git push' using ssh, your computer grabs id_rsa by default and uses that as its ssh identity.
  3. github can't (unsurprisingly) deconflict which account you mean, since it's basing the account off the key it is presented, which if tied to more than one account, leads to pain like this. The killer is, for a long time, I was getting away with this and things just worked out.

The entry I added is:

Host github.com
    Hostname github.com
    Port 22
    User waterproofpatch
    IdentityFile ~/.ssh/id_rsa_waterproofpatch

I had created a new key, unique to my account, as id_rsa_waterproofpatch. This entry in my ssh config specifies that for connections to github.com, I wish to present this key.

Another solution would probably have been for me to log into the other account, delete the duplicate ssh key.


clearing keychain didn't help... I had to ssh-add -D and re-add the key with ssh-add <keyfile>


I solved this problem removing (or renaming to *.bak) the id_rsa and id_rsa.pub file on MacOS High Sierra. Idea from here.

I have custom host redirects in ~/.ssh/config that should be applied but used wrong user before I renamed the two files...


That's what worked for me:

  1. Changing the credentials inside .git-credentials
  2. Changing the global user.name and user.email inside .gitconfig

What worked for me removing the repo and adding it again:

git remote rm origin
git remote add origin git@github.com:fguillen/MyApp.git

I have the same problem in windows10 even after uninstall my git, as @user542833 says it is because windows cache and you should remove Github credentials in your windows Credential Manager and when you again attempting to push, windows ask your credential and set it again


What worked for me was to use the Github repo's https URL instead of the ssh URL. I went to the Github project page and copied the https URL into my clipboard, and then pasted it into the second command below:

git remote rm origin
git remote add origin https://[...]

I had a similar issue and it turned out that the problem was the fact that the public key file contained my email address on the last line. That seemed to override the User setting in my config. As soon as I removed my email from the .pub file (and re-uploaded to my repo) Git connected using the correct user.

참고URL : https://stackoverflow.com/questions/21615431/git-pushes-with-wrong-user-from-terminal

반응형