본문 바로가기

SCM/Git

[ Git ] Git 자격증명 사용

프로젝트를 깃 허브등의 서버에 업로드 할 때 사용자 인증을 위한 아이디 및 패스워드가 필요하다.

개발 중 업로드 시 마다 아이디 및 패스워드를 치는 것이 불편하기 때문에 Credntial Helper 라는 것을 사용해

아이디 및 패스워드 입력을 생략할 수 있다.

 

깃허브의 경우 패스워드가 깃 허브 로그인 패스워드가 아닌 토큰이라고 하는 값을 패스워드로 사용한다.

토큰 발급 방법은 다음과 같다.

[ Settings ]
[ Developer settings ]
[ Personal access tokens ] → [ Generate new token ]
[ Token 관리 이름 ] → [ 토큰 유효기간 ] → [ repo 권한 ] → [ Gernerate token ]
토큰 값 복사하여 저장(다시 확인 X)

발급 받은 자격증명을 이용해서 Credntial Helper 를 이용하는 방법은 다음과 같다.

 

1. 공통

 

- 자격증명이 필요할 때마다 아이디/토큰 값 입력

# credential helper 삭제
git config --global --unset credential.helper

git config --system --unset credential.helper

 

- 자격증명을 일정시간 메모리에 저장하여 한번 입력후 메모리에 있는 자격증명을 사용

git config --global credential.helper cache

# 메모리 상주 시간 지정
git config credential.helper 'cache --timeout=3600'

2. Windows

 

- 자격증명을 파일로 저장하여 파일의 자격증명을 사용

# 파일명 지정 하지 않을시 디폴트 [ %USERPROFILE%\.git-credentials ] 로 저장
git config --global credential.helper store

# 파일명 지정하여 저장
# e.g. git config --global --file ~/git.store credential.helper store
git config --global --file [파일경로및파일명] credential.helper store

 

- 자격증명을 자격증명 매니저에 저장하여 사용

git config --global credential.helper manager-core

[ control /name Microsoft.CredentialManager ]
[ Windows 자격 증명 ] → [ 일반 자격 증명 추가 ]
[ git:https://github.com ] → [ 깃 사용자 아이디 ] → [ 깃 토큰 값 입력 ] → [ 확인 ]

3. Mac

 

- 자격증명을 파일로 저장하여 파일의 자격증명을 사용

# 파일명 지정 하지 않을시 디폴트 [ ~\.git-credentials ] 로 저장
git config --global credential.helper store

# 파일명 지정하여 저장
# e.g. git config --global --file ~/git.store credential.helper store
git config --global --file [파일경로및파일명] credential.helper store

 

- 자격증명을 자격증명 매니저에 저장하여 사용

git config --global credential.helper osxkeychain

[ Keychain Access 검색 ] → [ 키체인 접근 ]
[ 로그인 ] → [ 새로만들기 아이콘 ]
[ git:https://github.com ] → [ 깃 사용자 아이디 ] → [ 깃 토큰 값 입력 ] → [ 확인 ]
생성 확인

'SCM > Git' 카테고리의 다른 글

[ Git ] Git 컨벤션  (0) 2022.03.23
[ Git ] Git 명령어 활용  (0) 2022.03.21