[Git, Github] git hunk (코드 변경사항 단위)

JUNHO YEOM·2022년 11월 30일
0

Git, Github

목록 보기
15/27
post-thumbnail

git 세심하게 스테이징 하고 커밋하기

hunk

깃의 변경사항 단위를 hunk라고 합니다.

git add -p

깃의 변경사항 단위(hunk)를 하나씩 확인하면서 staging할지, 하지 않을 지를 정할 수 있습니다.

git add -p의 옵션

(1/1) 이 부분 스테이징합니까 [y,n,q,a,d,e,?]? 

git add -p명령을 사용하게 되면 각 변경사항 별로 여러가지 옵션을 선택하여 적용할 수 있습니다.

y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk or any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk or any of the later hunks in the file
e - manually edit the current hunk
? - print help 

각각의 옵션에 대한 설명은 다음과 같습니다.

hunk단위로 add할 때의 장점

hunk를 사용하면 같은 파일에 있는 변경사항도 hunk 단위로 다루어서
따로 처리할 수 있습니다.



변경사항을 확인하고 커밋하기

git commit -v

이번 commit에 담길 변화를 확인하고, commit 메시지를 작성할 수 있습니다.

git diff --staged

git diff --staged 이번 커밋에 담길 변경사항을 확인할 수 있습니다.
commit은 별개의 명령어로 진행합니다.

0개의 댓글