[Git] Github private repository(개인 저장소) cli로 clone 하는 방법? 정리!



Github에서 private repository(개인 저장소)를 만들고, 해당 repo를 clone 받으려면 아래와 같이 not found 오류 메세지가 나옵니다. (username은 meme / github_my_repo라는 private repository 에 접근하는 경우 아래와 같습니다)

$ git clone 'https://github.com/meme/github_my_repo.git' 

Cloning into 'github_my_repo'...
remote: Repository not found.
fatal: repository 'https://github.com/meme/github_my_repo.git' not found

이 경우 손쉽게 github.com 앞에 username@ 의 형식으로, username과 @를 붙여주면 정상적으로 동작합니다. 위에서 설명한 예제의 경우에는 meme@가 되겠죠!

위의 방법으로 동작하지 않는다면, username:personal_token값@ 과 같은 형식으로 :뒤에 token 값을 추가로 넣어주어야합니다. 위에서 설명한 예제의 경우에는 token이 sdfkjwn203498vh230dskfh271hjf012 라면 meme:sdfkjwn203498vh230dskfh271hjf012@ 이 됩니다!

image

$ git clone 'https://meme@github.com/meme/github_my_repo.git'
or 
$ git clone 'https://meme:sdfkjwn203498vh230dskfh271hjf012@github.com/meme/github_my_repo.git'

Cloning into 'github_my_repo'...
Password for 'https://meme@github.com': 
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/meme/github_my_repo.git/'

private 한 경우에도 위와 같이 손쉽게 다운로드 받을 수 있습니다! 정상적으로 동작하는 경우 비밀번호를 요구할 수 있는데요. 저처럼 처음 로그인 하는 경우에는 위와 같이 토큰을 요구할 수 있는데, 토큰을 입력하면 정상적으로 동작합니다!