gyunam.blog

[git] 기초 명령어

git 기초 명령어

init


git init

config


git config

repository 복제


git clone {url}

status 확인


git status

pull


git pull

branch 생성


git branch {to} {from}

example


git branch dev main

switch


git switch [branch]
git switch -c [branch]

파일 추가


git add {file or directory}

example


git add .(all)

commit


git commit -m "message"

push


git push origin dev

log

커밋 히스토리를 보려고 할 때 쓰는 명령어.


git log

히스토리에 있는 정보들이 복잡한 경우도 있기 때문에 여러가지 꾸밈 옵션들이 있다.

example


git log --pretty=oneline

show

특정 커밋의 변경사항을 볼 때 사용하는 명령어.


git show

방금 커밋 고치기

amend 는 고치다, 수정하다라는 뜻을 가지고 있다.


git commit --amend

alias

git 명령어가 길어질 때 매번 길게 치는게 귀찮으니까 만들어진 별명(alias)을 지칭하는 aliasing(앨리어싱) 명령어.


git config alias.history 'log --pretty-oneline'

diff

different 의 약자로, 두 커밋 사이의 차이점을 확인하는 명령어.


git diff a b