Github 명령어 정리

Haeun Kim·2022년 6월 23일
0

매일 github pull push 과정이 헷갈리는 나를 위한 백업,,

Github Repository 생성하기

  1. github 사이트에서 new버튼으로 새로운 repository를 생성한다.
  2. git init
  3. git add .
  4. git commit -m "commit message"
  5. git remote add origin github주소 - github의 주소로 remote하기
  6. git push -u origin master

branch 사용 기본 push

  1. git clone [url]
  2. git branch [branchname]
  3. git checkout [branchname]
  4. 작업
  5. git add .
  6. git commit -m "commit message"
  7. git push origin [branchname]
  8. pull request 작성

Git remote url 수정

  1. 기존 repository 주소 확인 : git remote -v
  2. 기존 repository 연결 해제 : git remote remove origin
  3. 새로운 repository 연결 : git remote add origin [새로운 Repository URL]

Git과 연결된 로컬 저장소 변경

.git 폴더를 이동시키면 된다

사진 출처 : https://sedangdang.tistory.com/147

Git 브랜치 생성/삭제

브랜치 생성 : git branch [branchname]
브랜치 삭제 : git branch -d [branchname]

Git 한번 pr 후 새로 시작할 때 과정

  1. 메인 branch 이동 후 master 내용 pull
    git checkout main
    git pull origin master
  2. 작업한 브랜치로 이동 후 master를 해당 브랜치에 merge
    git merge master

0개의 댓글