Tech Collection

[React] #0 기본 설치 - Git 본문

Build/Project

[React] #0 기본 설치 - Git

eee_269 2021. 10. 11. 00:30
728x90
반응형

이전 글


Git과 연동

1. Git Download

https://git-scm.com/

 

Git

 

git-scm.com

 

2. cmd 에서 버전 체크

>> git --version

3. vs code에서 git에 올리지 않을 파일 목록 생성

.gitignore 파일 생성 후 라이브러리가 있는 폴더인 node_modeules 는 올리지 않도록 수정 후 저장

4. vs code에서 terminal에 명령어 입력

>> git init

: .git 파일을 해당 프로젝트 폴더에 넣어줌으로써 git 과 연결시킴!

>> git add .

: 프로젝트의 모든 파일을 git에 추가

: 잘못 올린 파일의 경우 >> git rm --cached [지울 것의 이름] -r 실행!

>> git commit -m "메시지"

: git repository에 올릴 준비


이 단계에서, git bash에서 ssh 설정을 진행해야 한다!

Git Bash 에서 SSH Setting

아래의 문서를 참고하며 차례대로 진행

https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

 

Generating a new SSH key and adding it to the ssh-agent - GitHub Docs

After you've checked for existing SSH keys, you can generate a new SSH key to use for authentication, then add it to the ssh-agent.

docs.github.com

1. Git Bash 실행

2. 명령어 입력

>> ssh-keygen -t ed25519 -C "github 계정 이메일"

: 나는 이미 저장되어 있어서 덮어쓰기 했다.

: Enter passphrase 가 나오면 자신이 원하는 인증 비밀번호 설정!

: Enter save passphrase again 은 비밀번호 확인

3. ssh 생성 확인

>> ls -a ~/.ssh

: id_ed25519, id_ed25519.pub 있는지?


VS Code의 Terminal에서 git에 저장하기

>> git branch -M main

: 브랜치 지정

>> git remote add origin [github reopsitory 경로.git]

: git으로 접근 할 origin 경로 지정

: 처음 비어있는 저장소를 생성했을 때 나오는 url (뒤에 .git 이 붙어있어야 한다)

>> git push -u origin main

: origin 경로의 main 브랜치로 push

** 처음 저장소 생성 시 README.md를 생성해서 에러가 나는 경우

더보기

>> git push -u origin +main

: 브랜치 앞에 +를 입력하면서 강제로 덮어쓰게 할 수 있다.

 

728x90
반응형

'Build > Project' 카테고리의 다른 글

[React] #0 기본 설치 - node.js  (0) 2021.10.10