블로그 이미지
윤영식
Full Stacker, Application Architecter, KnowHow Dispenser and Bike Rider

Publication

Category

Recent Post

2012. 12. 12. 15:00 Git, GitHub/Git Lec01

git은 branch를 만들어 "테스트할 기능", "새로운 기능", "버그 픽스"등에 대하여 만들고, master에 다시 merge를 할 수 있다. branch를 만들고, merge하는 방법을 알아보자 



Git 제어

  • git branch new : 새로운 branch 를 만든다. 아무런 내역이 없다.
  • git checkout new : 새로 만든 new 브랜치로 이동한다 
  • git checkout -b alternate master : master를 복제하여 브랜치를 만들고 alternate로 checkout 이동한다 
  • git branch -m alternate alternative : 브랜치의 명칭을 alternative로 변경한다 (-M 기존 같은 명칭 브랜치 있어도 덮어씀)
  • git brranch -d alternative : alternative 브랜치를 삭제한다 (-D 옵션은 강제 삭제)


▶ Merge 전략 
  • Straight Merge (바로 합치기) : 브랜치 변경 이력 전체를 합치는 방법
  • Squashed Commit (커밋 합치기) : 한 브랜치 이력 압축하여 다른 브랜치의 최신 커밋으로 하나 만드는 방법
  • Cherry-picking (선택하여 합치기) : 다른 브랜치의 하나의 커밋을 현재 브랜치에 적용하는 방법

각 합치기에 대해서 위->아래 명령순으로 살펴보자 

> 바로 합치기 
  • git checkout -b alternate master
  • git add about.html (내용 넣음) -> git commit -m "add about"
  • git checkout master 
  • git merge alternate : master 브랜치에 alternate 브랜치를 합친다 (즉, about.html 파일이 신규로 합쳐짐)

> 커밋 합치기 
  • git checkout -b contact master
  • git add contact.html (주소 내역 추가) -> git commit -m "add contact address"
  • contact.html (email 내역 추가) -> git commit -a -m "add contact email" (즉, commit object 두개가 된다)
  • git checkout master
  • git merge --squash contact : contact의 커밋 두개를 하나로 만들어 master의 staging에 추가함 (git status 확인)
  • git commit -m "add contact address" -m "add contact email"  (master 브랜치에 contact.html 을 커밋한다)

> 선택하여 합치기
  • git checkout contact
  • git commit -a -m "add contact sns id" (contact.html안에 twitter 계정추가 commit object Hash 코드를 34abcd 로 가정함)
  • git checkout master
  • git cherry-pick 34abcd  ( contact 브랜치의 34abcd 커밋을 master 브랜치에 커밋한다)
  • git reset --hard HEAD 마지막 커밋을 master 브랜치에서 제거
  • git cherry-pick -n 34abcd ( -n 옵션 사용하면 master 브랜치의 staging에 넣음, 커밋안함. git status 로 확인)
  • git commit (최종 커밋함)


▶ Merge시 충돌 해소하기 

두개의 브랜치를 합치기하다 같은 파일의 내용이 동시에 변경되었을 경우 해결방법을 알아보자. 
  • git checkout -b about master : about 브랜치 생성 후 checkout
  • git add about.html (about 내역 입력) -> git commit -m "add about"
  • git branch about2 abut : about 브랜치를 기반하여 about2 브랜치를 생성
  • git commit -a -m "add XXX" : about 브랜치의 about.html 파일에 XXX 입력
  • git checkout about2 
  • git commit -a -m "add YYY" : about2 브랜치의 about.html 파일에 YYY 입력 (이제 about 브랜치의 about.html과 about2 브랜치의 about.html 파일에 XXX 와 YYY 충돌이 발생함)
  • git checkout about
  • git merge about2 : about2 브랜치를 about 브랜치로 바로 합치기
  • about.html 안에 conflict 내역이 표시됨 : 내역을 직접 수정하거나, git mergetool 명령으로 merge.tool 값 확인하고 도구로 합치기 시도함 (도구 사용법은 다시 상세히 봐야겠음)
<<<<<<<< HEAD : 밑으로 현재 브랜치 코드 나옴
>>>>>>>> about2 : 합치려는 다른 브랜치 코드 나옴
======= : 구분자

예) about.html 파일안의 conflict 내역
<<<<<<<< HEAD
XXX
=======
YYY
>>>>>>>> about2


'Git, GitHub > Git Lec01' 카테고리의 다른 글

[Git] tag 다루기  (0) 2012.12.20
[Git] Remote 저장소 연결 및 관리  (0) 2012.12.17
[Git] History 이용 및 관리하기  (0) 2012.12.13
[Git] Reset 사용하기  (0) 2012.12.11
[Git] Hash Object 정보보기  (0) 2012.12.11
posted by 윤영식
2012. 12. 11. 11:28 Git, GitHub/Git Lec01

Git의 로컬 Repository에 저장된 commit 내역에서 이전 commit 내역으로 이동하고 싶을 경우. HEAD를 조작함으로써 가능하다. 


  • 지금 까지 커밋 내역 보기 : git reflog  (하기 내역으로 파란색으로 3 번의 commit 이 존재한다)
git reflog
c6d5478 HEAD@{0}: commit: add license properties
aa64af1 HEAD@{1}: checkout: moving from master to rb_1.0
aa64af1 HEAD@{2}: checkout: moving from master to master
aa64af1 HEAD@{3}: merge rb_1.0: Fast-forward
e13af6f HEAD@{4}: checkout: moving from rb_1.0 to master
aa64af1 HEAD@{5}: commit: License Info about mqtt client for java
e13af6f HEAD@{6}: checkout: moving from master to rb_1.0
e13af6f HEAD@{7}: commit: add eclipse foundation software user agreement propert
475d6ae HEAD@{8}: clone: from https://github.com/ysyun/jmqtt_client.git


  • c6d5478 commit 내역에서 aa64af1 commit 내역으로 이동하기 : git reset --soft HEAD~  (staging, working 영향없음)
  • --mixed 는 staging을 local repository와 같게 만든다. 즉, staging에 HEAD정보를 복사하여 영향줌. working 영향없음 
  • --hard 는 staging, working 둘다 영향을 줌
$ git reset --soft HEAD~

yuwonsystem01@YSYUN91005152 /d/git-repositories/jmqtt_client (rb_1.0)
$ git reflog
aa64af1 HEAD@{0}: reset: moving to HEAD~
c6d5478 HEAD@{1}: commit: add license properties
aa64af1 HEAD@{2}: checkout: moving from master to rb_1.0
aa64af1 HEAD@{3}: checkout: moving from master to master
aa64af1 HEAD@{4}: merge rb_1.0: Fast-forward
e13af6f HEAD@{5}: checkout: moving from rb_1.0 to master
aa64af1 HEAD@{6}: commit: License Info about mqtt client for java
e13af6f HEAD@{7}: checkout: moving from master to rb_1.0
e13af6f HEAD@{8}: commit: add eclipse foundation software user agreement propert
475d6ae HEAD@{9}: clone: from https://github.com/ysyun/jmqtt_client.git

// git reset에서 이전 commit 이동하였으나 다시 앞선 커밋인 c6d5478 로 원복하고 싶을 경우
$ git reflog
aa64af1 HEAD@{0}: reset: moving to HEAD~
c6d5478 HEAD@{1}: commit: add license properties
// 위에서 HEAD@{1} 을 reset하면 다시 최신 HEAD로 간다 
$ git reset HEAD@{1}


  • aa64af1 commit 으로 이동했을 때 상태 정보를 확인 : git status  (c6d5478 commit 되기전 rename 명령을 내렸었음)
$ git status
# On branch rb_1.0
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       renamed:    license.dat -> license.properties

// 만일 staging에 있는 변경내역을 반영하고 싶지 않을 경우 
// 변경 파일이 하나 존재 
$ git status
# On branch feature_input_data
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified:   app/views/moving_average.html
#
no changes added to commit (use "git add" and/or "git commit -a")

// 설명문의 내역에 따라 파일이 있는 경로명과 함께 입력 
$ git checkout -- app/views/moving_average.html

// status로 다시 확인해 보면 방금 변경된 특정 staging에 있는 파일 내역을 이전 commit 당시 상태로 되돌려 놓았음
$ git status
# On branch feature_input_data
nothing to commit, working directory clean

  • Git 에서 HEAD, Branch는 Pointer이다 

* 참고 : 개발자를 위한 고급 Git 활용 (p100부터)


'Git, GitHub > Git Lec01' 카테고리의 다른 글

[Git] tag 다루기  (0) 2012.12.20
[Git] Remote 저장소 연결 및 관리  (0) 2012.12.17
[Git] History 이용 및 관리하기  (0) 2012.12.13
[Git] Merge 종류와 충돌 해결하기  (0) 2012.12.12
[Git] Hash Object 정보보기  (0) 2012.12.11
posted by 윤영식
2012. 12. 11. 11:02 Git, GitHub/Git Lec01

commit을 하여 Blob format으로 되어 있는 binary 파일에 대한 명칭은 SHA-1 해쉬알고리즘으로 해쉬명을 가지고 있다. 파일명과 해쉬명을 오가면 확인하는 방법을 알아보자 


  • 파일명 통하여 해쉬명 알아내기 : git hash-object <fileName>
$ git hash-object license.properties
b2ece065fd82ac65e5871a602166586fe691e3e7


  • 해쉬명 앞 6자리를 통하여 변경 내역이 무엇인지 파악하기 : git cat-file -p <해쉬명 앞 6자리>
$ git cat-file -p b2ece0
mqtt client for java version 1.0
written by ysyun, 2012


  • 전체 해쉬에 대한 파일명 맵핑 목록 보기 : git ls-files -s  ( .git/index 파일 내역을 참조함 )
$ git ls-files -s
100644 63bc96b980e4f36e5679312d4437908eb3add614 0       .classpath
100644 c349675aef6a30ee914d585a741bd742aad8b027 0       .project
100644 8e4055a6fa840c0bb4179360cee8a6e10352309f 0       .settings/org.eclipse.jdt.core.prefs
100644 8a6d87a1e842e58d1ea6bb707510c62f5eacc3d0 0       .settings/org.eclipse.m2e.core.prefs
100644 3ae4edb1acf2899b42b8ee6b9fd1c1ccb07cdd48 0       README.md
100644 026d2feeef3eccda9bbaae9db1ad251b9a436203 0       eclipse_feature.properties
100644 5ada071fd63361c553a5a1f7e9b816025e992c13 0       jmqtt_client-1.0.jar
100644 b2ece065fd82ac65e5871a602166586fe691e3e7 0       license.properties
100644 5f6e56a8381891e9ad64b61f58716ec7925ec5bb 0       pom.xml
100644 1fdcc8c6237579974f662d902f28d13f4c592580 0       src/main/java/MqttService.java




▶ Git의 4가지 객체


> Blob Object

  • Header + Content 
  • zlib으로 압축되어 있음
  • .git/objects/ 아래 있음 

> Tree Object
  • blob + 다른 tree 객체
  • 폴더와 같은 개념
  • .git/objects/ 아래 있음 

> Commit Object
  • blobs + trees + author + date + message
  • .git/objects/ 아래 있음

> Tag Object 
  • pointer to commit object
  • .git/refs/tags/ 아래 있음 


* 참고 : 개발자를 위한 고급 Git 활용 (p50부터)

'Git, GitHub > Git Lec01' 카테고리의 다른 글

[Git] tag 다루기  (0) 2012.12.20
[Git] Remote 저장소 연결 및 관리  (0) 2012.12.17
[Git] History 이용 및 관리하기  (0) 2012.12.13
[Git] Merge 종류와 충돌 해결하기  (0) 2012.12.12
[Git] Reset 사용하기  (0) 2012.12.11
posted by 윤영식
2012. 12. 10. 17:22 NodeJS/Concept

전역범위에서 참조가 가능한 글로벌 오브젝트. already defined object라고 할 수 있겠다. 



global objects 
> 하기 객체는 모든 모듈에서 이용할 수 있다. 실제 전역 범위를 가진다 
> node에서 var something의 something은 지역범위만 갖는다 
> global : {Object} 전역 네임스페이스 객체 
> process, console : {Object}
> Class: Buffer : {Function} 바이너리 데이터를 다루는데 사용 
> require() : 모듈 로딩으로 지역범위임
> __filename : {String} 실행되는 코드의 파일명 (코드의 절대경로 포함)
> __dirname : {String} 현재 실행되는 스크립트가 존재하는 디렉토리 경로 
> module : {Object} 현재 모듈에 대한 참조. 특히 module.exports는 exports 객체와 같다 
> exports : require()로 접근가능하게 된 모듈의 모든 인스턴스 사이에서 공유되는 객체다. 
> setTimeouts(cb, ms) : cb=callback, ms=milliseconds
  clearTimeout(t) : setTimeout()올 생성된 타이머를 멈춘다
> setInterval(cb, ms) : 반복적으로 callback 수행
  clearInterval(t)


>> fileName : globalTest.js

console.log(__filename);

console.log(__dirname);


>> 수행 

D:\Framework\Node.js> node globalTest

D:\Framework\Node.js\globalTest.js

D:\Framework\Node.js


'NodeJS > Concept' 카테고리의 다른 글

[Jade] Jade 사용하기  (0) 2012.12.15
[EJS] 사용하기  (0) 2012.12.15
[Node.js] File I/O 사용하기  (0) 2012.12.10
[Node.js] EventEmitter 에 대하여  (0) 2012.12.10
[Node.js] debugger 사용하기  (0) 2012.12.10
posted by 윤영식
2012. 12. 10. 17:00 Lean Agile Culture/Architecturing

SlideShare 링크 



posted by 윤영식