[Git] Command Line Interface

단군소프트에서는 4주마다 GitHub 교육을 진행하는데 이번 강의의 주제는 Command Line Interface
사용법이었다.

CLI의 장점


Git 저장소 구조


Image with caption Remote Repo는 Github에 만든 저장소
Working Directory, Staging Area, Local Repo 는 작업자의 PC


자주 사용하는 Git Command


- git init

- git add

- git add [file_name]: 특정 파일만 관리하도록 설정
- git add *.[확장자]: 특정 확장자 파일만 관리하도록 설정
- git add . : 추가된 모든 파일을 관리하도록 설정

- git status

- git diff

- git reset

- git reset HEAD [file_name]: 특정 파일을 working directory로 되돌릴 때 사용
- git reset: staging area에 있는 파일들을 모두 working directory로 되돌릴 때 사용

- git commit

- git commit -m "commit message" : staging area에 있는 내용을 Local 저장소에 저장
- git commit -am "commit message" : working directory에 추가된 항목을 git add를 
포함하여 커밋

- git branch

- git branch: 현재 모든 브랜치를 출력
- git branch [branch_name]: branch_name으로 신규 브랜치 생성
- git checkout [branch_name]: branch_name으로 브랜치 이동
- git checkout -b [branch_name]: branch_name의 신규브랜치 생성 후 해당 브랜치로 이동
- git branch -d [branch_name]: branch_name의 브랜치 삭제

- git merge

- git merge [branch_name]: branch_name 브랜치를 현재 브랜치로 병합
- git merge --squash [branch_name]: branch_name 브랜치의 여러 커밋을 하나의 커밋으로 병합
- git cherry-pick [commit_ID]: 특정 커밋만 병합

- git rm

- git rm --cached [file_name]: staging area에 있는 특정 파일을 추적하지 않도록 설정
(제거가 아님)

- git log

- git log --oneline: 커밋 이력 중 커밋 ID, 커밋 타이틀만 조회
- git log --oneline --decorate --graph --all: 모든 브랜치의 커밋 이력 조회
- git log --[file_name]: 특정 파일의 커밋 내역만 조회



출처: 단군소프트 “GitHub Webinar - CLI 사용법”

Discussion and feedback