Git은 왜 add를 시켜야 하는걸까?
commit 하기 전에 add를 시켜주는 이유에 대해서 알아보자.

이 때 선택적으로 파일을 


$ git add f1.txt


$ git status

On branch master

Changes to be committed:

  (use "git reset HEAD <file>..." to unstage)


        modified:   f1.txt    //쉽게 말하면 commit 대기 상태


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:   f2.txt


$ git commit    //commit 대기 상태에 있는 파일들만을 버전에 포함시킨다.

[master f6626ce] 4

 1 file changed, 1 insertion(+), 1 deletion(-)    //add 시킨 f1.txt만 선택적으로 commit이 된다.


  • 프로젝트시 여러 소스 코드를 수정하게 됨
  • commit 하나는 하나의 작업을 담고 있는 것이 이상적이지만, 많은 소스 코드를 수정하다 보면 commit을 놓치게 되는 상황이 생길 수 있다.
  • 그렇게 많은 작업들을 담은 거대한 버전 하나를 만들어야 할 때는 commit의 시기를 놓쳤을 때.
  • 이 때 git은 add라는 과정을 통해 commit을 할 수 있는 상태로 만들어준다.
  • commit 대기상태(stage area)에 있는 파일은 commit시 repository에 저장된다.


+ Recent posts