github

git 명령어로 workflow 수행

kjh42447 2022. 7. 1. 16:55
  • 혼자서

    1. fork한 repository 가져오기

      git clone repository명
      • repository 상태 확인

        git status
    2. 로컬 파일을 staging area로 이동

      git add 로컬파일명
    3. staging area의 내용을 commit

      git commit -m "커밋 명"
      • 커밋 취소

        git reset HEAD-1
        또는
        git reset HEAD^
    4. commit한 내용을 github repository에 등록

      git push repository명 branch명
      • 커밋 로그 확인

        git log
  • 여럿이

    1. git 초기화

      git init
    2. 리모트 연결

      git remote add 내repository명 링크
    3. 페어의 리모트 연결

      git remote add 페어repository명 링크
      • 리모트 확인

        git remote -v
    4. 페어의 작업물 가져오기

      git pull 페어repository명 branch명
    5. 페어와 merge된 작업물 등록

      git push 내repository명 branch명
  • 충돌 발생 시(같은 원격 repository에 같은 파일이 수정하여 pull할 경우, 충돌 발생)

    1. 충돌 부분 수정 후 staging area에 추가

      git add 로컬파일명
    2. commit(충돌 수정 후 staging area에 추가하면 자동으로 commit 메시지 생성됨)

      git commit
    3. push

      git push repository명 branch명
  • 브랜치 관련 명령

    1. 브랜치 목록 확인

      git branch
    2. 브랜치 생성

      git branch 브랜치명
    3. 브랜치 이동

      git checkout 브랜치명
    4. 브랜치 생성 후 해당 브랜치로 이동

      git checkout -b 브랜치명
    5. 브랜치 병합

      git merge 병합될브랜치명