ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [Git] Fork한 레포지토리 push 및 The requested URL returned error: 403 Push 에러 해결 방법
    Debug 2023. 11. 30. 13:06

     

     

    다른 사람의 Git Repository(레포지토리, A) 를 Fork(B) 및 Clone 한 후, (A) 레포지토리에 변경사항을 push하고 싶은 경우 방법에 대해 간략하게 설명하겠습니다.

     

    1. 대상 Repository(레포지토리, A) Clone

    # HTTPS
    git clone https://github.com/[ORIG_USERNAME]/[REPOSITORY].git
    
    # SSH
    git clone git@github.com:[ORIG_USERNAME]/[REPOSITORY].git

     

    2. 코드 변경

     

    3. git add & git commit 

     

    4-1. 다른사람의 Repository에 push 하고 싶을 때, collaborator 지정 필요 (Settings > Collaborators > Add people).

    • 초대된 Collaborator가 메일을 통해 수락 해야 활성화
    • 기본적으로 Collaborators들은 Read/Write 권한 모두 가짐

     

    5-1. 레포지토리 A에 push 하고 싶을 때, remote origin 지정 확인

    # 지정된 remote url 확인
    git remote -v
    
    # origin (fetch/push) 지정 안되어있는 경우, remote origin 설정
    git remote set-url origin https://github.com/[ORIG_USERNAME]/[REPOSITORY].git

     

    5-2. 다른사람의 Repository를 Fork 한 Repository (레포지토리, B)에 push 하고 싶을 때, 나의 아이디의 url로 설정된 remote upstream 지정 필요

    # 지정된 remote url 확인
    git remote -v
    
    # upstream (fetch/push) 지정 안되어있는 경우, remote upstream 설정
    git remote set-url upstream https://github.com/[MYUSERNAME]/[REPOSITORY].git

     

    6. push 하기

    git push origin [BRANCH]
    git push upstream [BRANCH]
    • 아이디와 비번(Token) 입력하라는 안내가 나오고, 정확하게 입력한 경우 push가 실행된다.
    • 403 Push 에러가 발생하는 경우는 권한 설정이 제대로 되어 있지 않은 경우이다.
      1. Push 대상 레포지토리의 Collaborator로 지정 되어 있는지 확인하기
      2. Origin / Upstream URL 설정 잘 되어있는지 확인하기
      3. 비밀번호로 사용하는 Token의 권한 범위 확인하기 (권한을 주지 않은 Token 사용시 이와 같은 에러가 발생하기 때문에 주의)
Designed by Tistory.