Git연동(PAT(Personal Access Token), SSH)
2022. 1. 6. 15:36ㆍ기타/Git
git 작업 접근 방법 변경에 따른 Github 연동 방법 정의
방법 1
1.PAT(Personal Access Token) 생성(기간 90일, 무제한은 비추)
2. osxkeychain 설정
git config --global credential.helper osxkeychain
3. PAT를 비밀번호로 설정
방법 2. SSH설정
1.
cd ~/.ssh
2. SSH key 생성
- 생성 시, 파일명(해당 문서에선 id-Github) 설정
ssh-keygen -t ed25519 -C "id@email.com"
or
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
2. 생성한 SSH public key 복사
cat id-Github.pub
3.github SSH key 등록
- 해당부분에 key 작성
4. ~/.ssh/config 수정(없다면 생성
vi ~/.ssh/config
Host github.com
HostName github.com
User {Git id} #git id
PreferredAuthentications publickey
IdentityFile /Users/sanghun/.ssh/{key파일} #파일위치
UseKeychain yes
AddKeysToAgent yes
5. ssh-add
ssh-add ~/.ssh/id-Github
6. ssh 접속 확인
ssh -T git@github.com
7. 기존 레포지토리를 clone 하고 있다면 ssh url로 변경
git remote set-url origin git@github.com:{Git ID}/{Repo}.git
7-1. fatal: not a git repository (or any of the parent directories): .git 에러 발생 시
fatal: not a git repository (or any of the parent directories): .git
- git init 진행 후 add
git init
git remote add origin git@github.com:{Git ID}/{Repo}.git
8. remote url 확인
git remote -v
권한 문제
설정을 제대로 했는데에도 불과하고 안되는 경우
에러내용
ERROR: Repository not found.
fatal: Could not read from remote repository.
git pull 호출 시 command 확인
GIT_SSH_COMMAND="ssh -v" git pull
'기타 > Git' 카테고리의 다른 글
유용한 git action 모음 (2) | 2025.04.10 |
---|---|
[Git 에러] fatal: Could not read from remote repository. (0) | 2024.02.21 |
git 대소문자 구별 (0) | 2021.12.21 |
[git ERROR] Your account is suspended. Please check with your installation administrator (0) | 2021.11.26 |
git index.lock (0) | 2021.11.26 |