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

Publication

Category

Recent Post

'Git fast-forward'에 해당되는 글 1

  1. 2013.01.13 [Git] fast-forward merge 를 위한 조건
2013. 1. 13. 20:00 Git, GitHub

git에서 merge를 할 경우 내용으로 fast-forward merge라는 용어가 나온다. 이에 대해서 알아보자.


1) fast-forwad merge 의 조건

  - master에서 새로운 branch를 만든다 

  - 새로운 branch에서 추가한 파일을 commit한다. 이때 master에서는 아무런 commit 내용도 없다.

   

//////////////////////////////////////////////////////

// cat branch를 만들고 cat으로 checkout 한다 (-b 옵션)

$ git branch -b cat


$ git branch

* cat

 master


///////////////////////////////////////////////////////////////

// 파일을 하나 만들고 commit 한다. 새로운 commit 이 생긴 것이다. 

$ echo "dowon" > cat.txt

$ git add cat.txt

$ git commit -m "add cat.txt"

[cat 1e6ea90] add cat.txt

The file will have its original line endings in your working directory.

 1 file changed, 1 insertion(+)

 create mode 100644 cat.txt


// cat branch안에 cat.txt 파일이 보인다

$ ls

README.md  build.gradle  cat.txt  todo.txt


// master branch로 이동을 한다 

$ git checkout master

Switched to branch 'master'

Your branch and 'origin/master' have diverged,

and have 1 and 3 different commits each, respectively.


////////////////////////////////////////////

// master에는 cat.txt 파일이 존재하지 않는다. 

$ ls

README.md  build.gradle  todo.txt


////////////////////

// merge를 수행한다

$ git merge cat

Updating 8ee3f5e..1e6ea90

Fast-forward

 cat.txt | 1 +

 1 file changed, 1 insertion(+)

 create mode 100644 cat.txt


////////////////////////////////////////////////
// 사용하지 않는 cat branch는 삭제한다. (-d 옵션)
$ git branch -d cat 


posted by 윤영식
prev 1 next