반응형

퇴근 후 기획자 친구와 사이드 프로젝트를 진행하면서 그 친구가 git hub에 올린 프로젝트를 IDE vs code로 git clone을 해서 내려받았다. 코드를 수정하고 새로운 파일을 추가하면서 git add와 git commit까지 끝마쳤으나 git push가 되지 않았다!

git push origin main을 썼는데 git bash창에서 아래와 같은 문구가 나왔다.

$ git push origin main

remote: Permission to 친구_github_이름/프로젝트_제목.git denied to 내_전역github_이름.

fatal: unable to access 'https://github.com/친구_github_이름/프로젝트_제목.git/': The requested URL returned error: 403

그래서 다시 git commit을 했는데 이런 문구가 나왔다.

$ git commit -m "login.html 추가 및 my-app 내 App.js 일부 수정"
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

이 뜻은 이미 commit이 됐다는 얘기로 git push만 하면 된다는 얘기다. 워킹트리 자체도 깨끗하기에 git add도 할 필요가 없었다.

한참을 고민하다가 내 github이름을 전역으로 설정한 기억이 났다.(맨 위 코드블록 참조) 이 친구가 나를 초대했을 때 내가 사용하지 않은 전역이름을 가진 메일 계정으로 초대했기 때문에 이런 일이 생겼을 거라고 판단했다.

원래 전역으로 사용하고 있는 계정은 gmail 계정이었으나 이 친구가 초대장을 보낸 메일은 naver 계정이었기에 이름 역시 다르게 사용하고 있었다. 이것은 git log를 확인해보니 더 명확했다.

$ git log
commit 727091c708b30539ea72a304daed104c9ca38044 (HEAD -> main)
Author: 내_github_이름 <메일ID@naver.com>
Date:   Sat Dec 2 19:23:54 2023 +0900

    login.html추가, App.js 수정 및 모듈추가

혹시 몰라서 원격서버에 연결이 안됐기 때문이라고 생각했지만 원격서버에도 잘 연결돼 있었다.

$ git remote -v
origin  https://github.com/친구_github이름/repository.git (fetch)
origin  https://github.com/친구_github이름/repository.git (push)

구글링 끝에 local 영역에서 내 github user.name과 user.email을 바꿔야 한다는 것을 알아서. git config로 확인해보니 나는 네이버 계정ID와 그 계정에 해당되는 이름을 사용하고 있었다. 

$ git config user.name
내_local_user.name

$ git config user.email
내_naverID@naver.com

$ git push
remote: Permission to 친구_github_이름/repository denied to 내_전역github이름.
fatal: unable to access 'https://github.com/친구_github_이름/repository/': The requested URL returned error: 403

계속 뫼비우스의 띠를 걸어가고 있었고 구글링은 두 시간이나 지속됐다. 이 push 하나를 위해서!!!

드디어 오랜 구글링 끝에 발견한 git 명령어가 있었다.

$ git config credential.username "전역이 아닌 해당 워킹 디렉토리 내부의 내_github이름"

$ git push
Enumerating objects: 29817, done.
Counting objects: 100% (29817/29817), done.
Delta compression using up to 4 threads
Compressing objects: 100% (23503/23503), done.
Writing objects: 100% (29783/29783), 91.32 MiB | 5.14 MiB/s, done.
Total 29783 (delta 5083), reused 29763 (delta 5063), pack-reused 0
remote: Resolving deltas: 100% (5083/5083), completed with 19 local objects.
To https://github.com/친구github이름/repository
   5c330d14..727091c7  main -> main

바로 git config credential.username이었다!!!!

이 문제를 해결해준 stackoverflow 링크다.

https://stackoverflow.com/questions/47465644/github-remote-permission-denied

 

Github remote permission denied

I'm trying to upload my repo on github and go through all the steps up to: git push -u origin master at that point it gives me the following error: remote: Permission to samrao2/manager-4.git deni...

stackoverflow.com

앞으로 git 공부도 해야될 것 같다. 간단한 git pull, git push도 이렇게 힘들다는걸 몸소 깨닫는 순간이었다.

반응형

+ Recent posts