작업 디렉토리 초기화 (.git 디렉토리를 만듦) $ cd Git (작업 디렉토리) $ git init
임시 영역 "index"에 저장 $ tar xzf Squawk.tar.gz $ git add Squawk/
리파지토리 "stage(--cached)"에 저장 $ git commit -m "Initial Importing" (use "git rm --cached ..." to unstage)
새 파일을 "index"에 추가 $ git add Makefile
새 파일을 리파지토리 "stage(--cached)"에 저장 $ git commit (use "git reset HEAD ..." to unstage)
파일을 수정하기 $ vi Makefile $ git diff Makefile (작업디렉토리와 "index" 비교)
수정한 파일을 "index"에 저장 $ git add Makefile
수정한 파일을 "stage(--cached)"에 저장 $ git diff --cached Makefile (option) $ git status Makefile (option) $ git commit
수정된 파일들을 자동으로 인식해서 index에 넣고 커밋까지 한꺼번에 하는 방법 $ git commit -a
프로젝트 히스토리 $ git log (주석을 리스트) $ git log -p (주석과 함께 변경된 내용을 리스트) $ git log --stat (주석과 함께 파일스텝라인 리스트)
Branch 만들기 및 Branch에서의 수정 작업 $ git branch translation_KR (translation_KR Branch에서 작업하기) $ git branch (branch 리스트) $ git checkout translation_KR (working branch를 translation_KR로 switching) $ vi CoreSquawk/Dog.cpp $ git commit -a
"master" Branch에서 수정 $ git checkoutmaster (master Branch에서 작업하기) $ vi CoreSquawk/Dog.cpp $git commit -a
Branch 작업을 "master" Branch로 merge 하기 $ git config --global mergetool.keepBackup false (base,remote,local backup파일 보관여부) $ git merge translation_KR Auto-merged Squawk/CoreSquawk/Dog.cpp CONFLICT (content): Merge conflict in Squawk/CoreSquawk/Dog.cpp Automatic merge failed; fix conflicts and then commit the result. $ git diff master(LOCAL):Squawk/CoreSquawk/Dog.cpp <<<<<<< bow_wow = "Grrrrrrr"> bow_wow = "멍멍멍">>>>>>> translation_KR(REMOTE):Squawk/CoreSquawk/Dog.cpp
meld GUI를 이용한 merge 작업 $ git mergetool -t meld 참고 : Comparing and merging files with Meld http://www.linux.com/archive/feature/61372 $ git commit -a $ gitk (for project's graphical history browser) $ git branch -d translation_KR (after merge) $ git branch -D translation_KR (remove branch anyway)
다른 작업 디렉토리 또는 다른 작업자가 작업하기 $ git clone Git Git2 (will create Git2 directory and copy files & project histories) $ cd Git2 (작업 디렉토리) $ vi Squawk/CoreSquawk/Cat.cpp $ git commit -a $ gitk
다른 작업 디렉토리 또는 다른 작업자 결과를 가져와서 merge하기 $ git pull ../Git2 master (다른 작업 영역의 master 브랜치를 현재 작업 브랜치로 가져옴) $ gitk