Git연동(PAT(Personal Access Token), SSH)

2022. 1. 6. 15:36기타

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

'기타' 카테고리의 다른 글

Google SearchConsole 등록방법  (0) 2023.07.12
mac 모니터 방향 인식 오류  (0) 2022.07.08
zsh 환경세팅(m1 terminal)  (1) 2022.01.05
Ubuntu(20.04) SSH설정  (0) 2021.10.25
Rasberry PI 4 무선인터넷 설정  (0) 2021.10.25