기타/(링크)유용한 정보

git 명령어 모음

리꾸엘메 2022. 3. 18. 13:58

https://hackmd.io/@oW_dDxdsRoSpl0M64Tfg2g/ByfwpNJ-K

https://mi2mic.tistory.com/186


1. 처음 코드 업로드

 

(로컬에 cra 폴더 만들어서 업로드 하는 경우)

cra폴더를 만든 후 깃헙에서 레포지토리 만들어서 그대로 복붙 후 터미널에 붙여넣기

git remote add origin https://github.com/Co-Ji/123.git
git branch -M main
git push -u origin main

 

(처음 파일 만들어서 업로드 하는 경우 )

초기화: git init 

파일 더하기(add: 모두): git add .

확인: git status 

히스토리 만들기("버전이름"): git commit -m "first commit"

깃헙repository와 내 로컬 폴더 연결(깃헙-코드-클론에서 주소 복붙): git remote add origin 복붙주소

확인: git remote -v

업로드: git push origin master      // master는 본체이다. branch이름을 적으면 된다.

(이제 master 보다 main 을 쓰라고 한다. 그래서 master를 main으로 바꾸니 에러가 난다. 방법을 찾아봐야 할듯) 

 

 

2. 이후 코드 업데이트

git add .

git commit -m "버전이름"

git push origin 브랜치이름

 

3. 협업 할 때 branch 만들기

1) 최초로 프로젝트 받아오기 : git clone '레포지토리 주소'

2) 브랜치 생성: git branch 브랜치이름  

3) 브랜치 확인 : git branch 

4) 브랜치 입장 : git checkout 브랜치이름

5) 메인에서 변경파일 받아오기: git pull origin main

6) 브랜치에 파일 커밋: 

git checkout 브랜치이름
git add .
git commit -m '수정내용'
git push origin 브랜치이름
홈페이지에서 풀 리퀘스트 - 확인 후 머지