Git 명령어 총정리 [210121 업데이트]

우현민·2021년 1월 18일
0

Git 개념 총정리

목록 보기
4/4
post-thumbnail

매우 긴 문서가 될 것이기 때문에 ctrl+f 또는 ⌘ + f를 하고 원하는 걸 검색하면 된다.
자주 쓰이는 것만 정리하기 때문에, 가령 git checkout --ignore-skip-worktree-bits같은 건 없다..

무슨 순서로 정렬해야 될지 모르겠어서 사전순으로 한다.


add

설명file을 stage한다.
사용법git add <file>
예시git add src/App.js
예시git add .

clone

설명cloud에 있는 repository를 local로 다운받는 명령어이다. shell에서 현재 있는 위치의 하위 디렉토리로 <repository name>/ 폴더가 생긴다.
사용법git clone <repository link>
예시git clone https://github.com/woohm402/null.git

commit

설명마지막 커밋 이후 변화를 저장한다
사용법git commit [options]
예시git commit -a -m "button bug fixed"
git commit -m "button bug fixed"
git commit --amend

checkout

설명local에 있는 코드를 다른 브랜치의 코드로 전환하고, git 설정을 그 브랜치로 옮긴다.
사용법git checkout [options] <branch name>
예시git checkout -b Button#42 main
git checkout Button#42

fetch

설명서버에 있는 코드를 로컬의 리모트 저장소로 불러옴(로컬 코드가 변하진 않는다)
사용법git fetch [remote name] [branch name]
예시git fetch

init

설명로컬 폴더를 git repository workspace로 만듦
사용법git init
예시git init

log

설명수정 내역(커밋 메세지 등)을 확인
사용법git log
예시git log

pull

설명fetch + merge
사용법git pull [remote name] [branch name]
예시git pull
git pull origin master

push

설명local에 있는 커밋 내역을 서버에 적용
사용법git push [options]
예시git push

remote

설명현재 git의 remote 저장소들을 관리
사용법git remote [options]
예시git remote add origin https://github.com/woohm402/null.git
git remote -v
git remote remove origin

stash

설명수정 내역을 버리고 코드를 마지막 커밋 상태로 되돌림
사용법git stash
예시git stash

status

설명로컬 repository workspace의 상태를 확인
사용법git status
예시git status

profile
프론트엔드 개발자입니다

0개의 댓글