실습 환경 : ubuntu
1. SSH 인증 및 연동
깃에 업로드하기 위해 인증을 진행해야 함.
기존엔 패스워드 인증을 했지만, 더 이상 패스워드 인증을 진행하지 않아 Token 또는 SSH로 인증을 해야 함.
토큰 인증은 유효기간이 있어 매번 인증해줘야 하므로 SSH 선택
키 생성 및 복사
# key 생성
$ ssh-keygen -t ed25519 -C "urtbest86@gmail.com"
# ~/.ssh로 이동하여 잘 키 잘 생성되었나 확인
$ cd ~/.ssh
$ ls -l
-rw------- 1 user user 411 8월 21 18:31 id_ed25519
-rw-r--r-- 1 user user 101 8월 21 18:31 id_ed25519.pub
# 자동 ssh위해 ssh-agent에 개인 키 등록 (config파일하지 않아도 됨.)
$ ssh-add ~/.ssh/id_ed25519
# 퍼블릭 키 id_ed25519.pub 내용을 복사
$ cat id_ed25519.pub
Git에 키 등록
github페이지 -> setting -> SSH and GPG keys -> New SSH key에 복사한 퍼블릭 키 등록
SSH 접속 확인
$ ssh -T git@github.com
Hi urtbest86! You've successfully authenticated, but GitHub does not provide shell access.
2. git Clone
원하는 저장소에서 SS를 복사
$ git clone git@github.com:urtbest86/Study-ML.git
#clone을 하면 디렉터리가 생성됨.
#해당 위치로 이동
$ cd Study-ML
3. 내 정보 등록
# 이름
$ git config --global user.name youjin
# 이메일
$ git config --global user.email urtbest86@gmail.com
# 결과를 컬러로 출력해 쉽게 구분해줌.
$ sudo git config --global color.ui "auto"
4. git remote origin
$ git remote add origin git@github.com:urtbest86/Study-ML.git
####필요 시###
#현재 remote 상태 확인
$ git remote show
#기존 remote 삭제
$ git remote remove orgin
5. git add
등록할 파일 선택
#모든 파일 add
$ git add .
#파일 지정
$ git add test.txt
6. git commit
커밋 메시지 입력
$ git commit -m "메시지입력"
7. git push
올리기
$ git push origin master
git status
상태 확인
$ git status
git pull
git 저장소 내용들 가져오고 현재 로컬 상태와 병합
$ git pull