190813 bridge-course Git branch add commit

Branch?

zenibako.lee
4 min readAug 13, 2019

프로젝트 변경사항을 branch 별로 나누고,

필요에 따라 merge를 통해 다시 한 줄기로 통합.

git branch -d branchname : delete branch

git checkout -b branchname : 해당 branch 있을 경우 해당 branch로 switch, 없을 시 생성 후 switch.

git merge 가져올branch // merge는 branch정보를 흡수할 branch에서 사용가능.

.gitignore

해당 file or directory를 git에서 관리하지 않겠다.

ex) echo file01 >> .gitignore

= .gitignore파일에 vi editor 없이 바로 file01을 append.

> 한개만 붙을 경우 overwrite.

.gitignore 옵션 커맨드 목록.

다양한 사용법이 자세히 나와있음.

echo file01 >> .gitignore // file01을 .gitignore아래로 이동 (git에서 제외)

git rm — — cached file01 // git에서는 지우지만 파일자체는 변화 x

이후 commit을 하고나서 file01에 대해 변화를 해도 status에 잡히지 않음.

git check-ignore -v file01

file01이 git에서 ignore되고있나 확인

git add

git add option

  • git add . 의 경우 pwd기준으로 변화를 감지하기 때문에 working directory가 root가 아닌 경우 git add -A 와 다른 결과가 발생.
  • git reset file01 을 통해 add 작업 취소 가능.

return되는 변경사항의 하나의 단위 = hunk

hunk단위로 y/n을 하려면 s를 입력.

.gitinclude

git은 디렉토리가 아닌 파일의 변화를 감지.

따라서 빈 디렉토리를 필요에 따라 add, commit 해야 할 경우 사용.

ex) touch dir01/.gitinclude (.gitinclude 숨김파일이 포함된 dir01 디렉토리 생성)

이후 add, commit 가능.

git commit

git commit options

: 가장 최근의 commit message vi editor가 열림.

수정없이 저장하면 그 전 commit log에 합쳐짐.

git show $commitnum 을 통해 해당 log확인 가능.

좋은 git 커밋 메시지를 작성하기 위한 7가지 약속

  1. 제목과 본문을 한 줄 띄워 분리하기
  2. 제목은 영문 기준 50자 이내로
  3. 제목 첫글자를 대문자로
  4. 제목 끝에 . 금지
  5. 제목은 명령조
  6. 본문은 영문 기준 72자마다 줄 바꾸기
  7. 본문은 어떻게보다 무엇을, 에 맞춰 작성하기

출처 : https://meetup.toast.com/posts/106

--

--

zenibako.lee
zenibako.lee

Written by zenibako.lee

backend engineer, JS, Node, AWS

No responses yet