Git, 분산 버전 관리 시스템 3장 첫 프로젝트 만들기 본문

Programming

Git, 분산 버전 관리 시스템 3장 첫 프로젝트 만들기

halatha 2010. 4. 20. 12:50
3.1 저장소 생성
$ mkdir mysite
$ cd mysite
/mysite$ git init
Initialized empty Git repository in /home1/irteam/naver/work/jun/TEST/mysite/.git/

3.2 변경하기
/mysite$ vi index.html
/mysite$ git add index.html
/mysite$ git commit -m "add in hello world HTML"
[master (root-commit) 3a35bf9] add in hello world HTML
 1 files changed, 5 insertions(+), 0 deletions(-)
 create mode 100644 index.html
/mysite$ git log
commit 3a35bf9bcc7f02292717ac36e2203df4a0fede17
Author: your name <your.name@somesite.com>
Date:   Tue Apr 20 12:27:24 2010 +0900

    add in hello world HTML

3.3 프로젝트를 이용한 작업 시작하기
/mysite$ git status
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   index.html
#
no changes added to commit (use "git add" and/or "git commit -a")
/mysite$ git add index.html
/mysite$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   index.html
#
/mysite$ git commit -m "add <head> and <title> to index" \
> -m "This allows for a more semantic document"
[master 13c58ab] add <head> and <title> to index
 1 files changed, 3 insertions(+), 0 deletions(-)
/mysite$ git log -1
commit 13c58abd441f13ecc822b9c85fda5be094820b87
Author: Hyunjun Jeong <hyunjun.chung@nhn.com>
Date:   Tue Apr 20 12:31:27 2010 +0900

    add <head> and <title> to index

    This allows for a more semantic document

3.4 브랜치 사용하고 이해하기
/mysite$ git branch RB_1.0 master    #    master에서 RB_1.0 브랜치 생성
/mysite$ git commit -a    #    편집기 실행

".git/COMMIT_EDITMSG" 10L, 296C written
[master 8e93d89] add <ul>, <li> and <a> in index.html
 1 files changed, 3 insertions(+), 0 deletions(-)

/mysite$ git checkout RB_1.0    #    브랜치 변경
Switched to branch 'RB_1.0'

/mysite$ vi index.html    #    <meta> tag 추가

/mysite$ git commit -a

".git/COMMIT_EDITMSG" 10L, 284C written
[RB_1.0 06aa878] add <meta> in index.html
 1 files changed, 1 insertions(+), 0 deletions(-)

3.5 릴리스 다루기
/mysite$ git tag 1.0 RB_1.0    #    1.0 릴리스에 대한 태그
/mysite$ git tag
1.0

/mysite$ git checkout master    #    마스터 브랜치로 전환
Switched to branch 'master'
/mysite$ git rebase RB_1.0    #    브랜치 재정렬
First, rewinding head to replay your work on top of it...
Applying: add <ul>, <li> and <a> in index.html
/mysite$ git branch -d RB_1.0    #    릴리스 브랜치 삭제
Deleted branch RB_1.0 (was 06aa878).

/mysite$ git branch RB_1.0.1 1.0    #    릴리스 브랜치 없이 1.0.x 브랜치에 대한 패치를 생성하기 위한 브랜치
h7b256:/home1/irteam/work/jun/TEST/mysite$ git checkout RB_1.0.1
Switched to branch 'RB_1.0.1'
h7b256:/home1/irteam/work/jun/TEST/mysite$ git log --pretty=oneline
06aa87884532a1a1469152580737637e18a2d29f add <meta> in index.html
13c58abd441f13ecc822b9c85fda5be094820b87 add <head> and <title> to index
3a35bf9bcc7f02292717ac36e2203df4a0fede17 add in hello world HTML

/mysite$ git archive --format=tar \
>                    --prefix=mysite-1.0/ 1.0 \
>                    | gzip > mysite-1.0.tar.gz
/mysite$ ls
./  ../  .git/  index.html  mysite-1.0.tar.gz

/mysite$ git archive --format=zip \
>                    --prefix=mysite-1.0/ 1.0 \
>                    > mysite-1.0.zip
h7b256:/home1/irteam/work/jun/TEST/mysite$ ls
./  ../  .git/  index.html  mysite-1.0.tar.gz  mysite-1.0.zip

3.6 원격 저장소 복제하기
$ git clone git://github.com/tswicegood/mysite.git mysite-remote
Initialized empty Git repository in /home1/irteam/naver/work/jun/TEST/mysite-remote/.git/
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (8/8), done.
Receiving objects: 100% (12/12), 1.29 KiB, done.
Resolving deltas: 100% (2/2), done.
remote: Total 12 (delta 2), reused 0 (delta 0)
$ ls mysite-remote/
./  ../  .git/  index.html

Comments