로컬 Git 리포지토리와 GitHub의 리포지토리를 연동하는 방법
가. Git 초기 설정:
- Git을 설치한 후, 사용자 이름과 이메일 주소를 설정합니다.
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
나. 로컬 리포지토리 생성 및 초기화:
mkdir myblog
cd myblog
git init
라. 커밋 생성:
git add .
git commit -m "Initial commit"
마. GitHub 리포지토리와 연결:
- 이전 글에서 안내한 Github 저장소 생성 주소를 입력
"https://github.com/caizer10st/myblog.git" 대신 본인 레포지토리 주소 입력
git remote add origin https://github.com/caizer10st/myblog.git
바. Personal Access Token (PAT) 생성:
- GitHub 계정으로 로그인 후, [Settings] > [Developer settings] > [Personal access tokens]로 이동합니다.
- 새 토큰을 생성하고, 필요한 권한을 선택합니다.
- 토큰을 안전하게 저장합니다.
사. Git Credential 저장:
- Git에서 GitHub 사용자 이름과 PAT를 사용하여 로그인합니다.
git config --global credential.helper store
- 다시 푸시를 시도하면, 사용자 이름과 암호 대신 PAT를 입력합니다.
- 21년8월13일부터 Https를 통한 암호 인증 종료됨.
git push origin master
- 이후 Git은 사용자 이름과 토큰을 저장하여 추후 인증 과정을 자동으로 처리합니다.