[Git Error] remote: Permission to ooo denied to ooo.

Yuri Lee·2021년 1월 15일
1

배경

나는 git 계정을 2개 사용하고 있다. 원래 개인 git 계정만 사용하다가 회사 프로젝트를 진행할 때 불편함을 느껴 회사용 git 계정을 추가했었다.

  • 개인 계정 (global 설정)
  • 회사 계정

git 설정 파일

~/.ssh/config 파일

# Default GitHub
Host github.com
 HostName github.com
 IdentityFile  ~/.ssh/id_rsa
 User git


# work 
Host github.com-work
   HostName github.com  
   IdentityFile ~/.ssh/id_rsa_work
   User git  

.gitconfig

[user]
	email = sample@gmail.com
	name = sample
[includeIf "gitdir:D:/company-project/"]
  path = .gitconfig-work

회사 프로젝트를 D드라이브의 company-project 폴더 내에서 관리하도록 했다.

.gitconfig-work

[user]
  email = sample-work@gmail.com
  name = sample-work

Error

Permission to sample-work denied to sample.

voscode 터미널 내에서 git test를 통해 push 를 하려고 했지만 위와 같은 에러가 발생했다.😫 구글링ㄱㄱㄱ

해결

windows 자격 증명 관리자 방법이 대다수였지만 나에게 통하지 않았다. git remote set-url 설정을 해봤다. 회사 프로젝트 내에 있는 폴더이므로 remote 주소에 config 파일에서 설정해준 git@github.com-work 를 넣어주었다.

PS D:\company-project\wtf> git add .
PS D:\company-project\wtf> git commit -m "Fix"
[main eafc8e9] Fix
remote: Permission to sample-work/wtf.git denied to sample.
fatal: unable to access 'https://github.com/sample-work/wtf.git/': T
PS D:\company-project\wtf> git remote set-url origin git@github.com-work
PS D:\company-project\wtf> git remote -v

다시 파일을 add 후 commit, push 해보자.

PS D:\company-project\wtf> git add .
PS D:\company-project\wtf> git commit -m "Add app.css"
PS D:\company-project\wtf> git push
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 325 bytes | 162.00 KiB/s, done.
Total 4 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To github.com-work:sample-work/wtf.git

깔끔하게 잘 올라간 모습을 볼 수 있다.


https://recoveryman.tistory.com/392

profile
Step by step goes a long way ✨

0개의 댓글