Git 터미널 명령어

hoBahk·2021년 10월 7일
0

터미널 명령어

  • remote repository의 코드를 clone

    % git clone [remote repository URL]

  • 현재 위치에서 Local Repository를 생성

    % git init

  • Git의 상태를 확인

    % git status

  • [파일명]을 stage에 올림

    % git add [파일명]

commit

  • commit 메시지를 붙여서 commit

    % git commit -m "[메시지]"

  • commit 내역 확인

    % git log

reset & revert

  • reset 명령어

    % git reset [commit hash]
    % git reset --soft [commit ID] // head만 바뀐다. // [commit hash]로 해도 가능

    % git reset --mixed [commit ID] // staging도 바뀐다. // [commit hash]로 해도 가능

    % git reset --hard [commit ID] // working 디렉터리, staging 모두 바뀐다. // [commit hash]로 해도 가능

  • revert 명령어

    % git revert [commit hash]

branch

  • branch 생성

    % git branch [브랜치명]

  • branch 조회

    % git branch

  • branch 이동

    % git checkout [브랜치명]
    % git checkout -b [브랜치명] // branch 생성 + 이동

  • branch 병합(merge)

    % git merge [브랜치명]
    % git merge [브랜치명] --edit // 병합 후 바로 vi 편집기가 나와 커밋 메시지 수정 가능하다.

pull & push

  • remote repository 에 연결

    % git remote add [remote][github URL]
    % git remote add [remote][브랜치명]

  • remote repository 에 연결됐는지 확인

    % git remote -v

  • remote repository 에 업로드

    % push [remote][브랜치명]

  • remote repository의 commit을 Local repository로 가져옴

    % git pull [remote][브랜치명]

profile
호박에 줄 그어서 수박 되는 성장 드라마

0개의 댓글