Skip to content
thomas edited this page Feb 28, 2018 · 3 revisions

Table of Contents

설정값 확인

 git config --list

Git 저장소 만들기

 git init
 git clone <url>

파일의 상태 확인하기

 git status

파일을 새로 추적하기

 git add <filename>

파일 상태를 간단히 확인

 git status -s

파일상태 비교

 git diff
 git diff --staged
 git diff --cached

변경사항 커밋하기

 git commit
 git commit -m "커밋내용"
 git commit -a -m "파일추가하면서 커닛하기"

파일삭제

 git rm <filename>

파일이름 변경

 git mv <file_from> <file_to>

커밋 히스토리 조회하기

 git log
 git log -2					;최근 2개
 git log -2 -p					;diff내용포함
 git log --stat					;각 커밋의 통계정보
 git log --pretty=format:"%h %s" --graph
 git log --oneline --decorate --graph --all
 git log --since=2.weeks
 git log --S<pattern>

되돌리기

 git commit --amend

리모트 저장소

 git remote
 git remote -v
 git remote add <short_name> <url>		;리모트 저장소 추가.
 git remote rename <org> <new>			;리모트 저장소 이름 변경
 git remote rm <name>				;리모트 저장소 삭제
 git remote show origin				;원격저장소 살펴보기
 git push origin master				;리모트 저장소에 Push

태그 조회하기

 git tag
 git tag -l '패턴'

브랜치

 git branch <branch_name>			;브랜치 생성
 git checkout <branch_name>			;해당 브랜치로 이동	
 git checkout -b iss53				;브랜치생성+체크아웃
 git checkout -b hotfix
 git commit -a -m '오류 수정 후 커밋'
 git checkuot master				;master로 이동 후
 git merge hotfix				;hotfix 브랜치를 머지한다.
 git branch -d hotfix				;hotfix 브랜치를 삭제한다.
 git branch -v					;브랜치마다 마지막 커밋 메세지를 보여준다.
 git branch --merged				;이미 branch한 목록을 확인한다.
 git branch --no-merged				;현재 checkout 한 브랜치에 merge하지 않은 브랜치를 확인한다.

GUI

 git gui					;on Windows