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

  • 본문은 어떻게보다 무엇을, 왜에 맞춰 작성하기
  • 제목과 본문을 한 줄 띄워 분리하기
  • 제목은 영문 기준 50자 이내로
  • 제목 첫글자를 대문자로
  • 제목 끝에 . 금지
  • 제목은 명령조로 (영어)
  • Github - 제목(이나 본문)에 이슈 번호 붙이기
  • 본문은 영문 기준 72자마다 줄 바꾸기

참조

Git useful command

이미 추가된 파일을 local 엔 남기고 저장소에서만 삭제하고 싶을 때

git rm -r --cached bin/

Https credential save

git config --global credential.helper store

Commands

checkout

  • git checkout -b fetch_head origin/master : fetch 이후에 origin 을 미리 보고자할 때

Branch list

  • git branch
  • git branch -r
  • git branch -a

Fetch

  • git fetch origin branch:branch: Fetches and updates a local branch from the remote branch.

Branch Prune

origin으로 추가한 리모트에 있는 브랜치가 삭제되었을 때, 로컬에서도 삭제

  • git remote prune origin
  • git remote update --prune

push

  • git push origin --delete test : delete remote branch

checkout

  • git checkout -b <new_branch_name> <SHA1> git branch branchName + git checkout branchName

pull

  • git pull --rebase origin/master : git forward porting

rebase

  • git rebase -i HEAD~2 : rebase interfactive

merge

  • git merge --squash : Squash merge : 여러 커밋을 하나로 만들어서 넣는다. branch 연결고리가 사라진다.
  • git branch -f master SHA-1 : 브랜치를 특정 commit 으로 강제로 옮긴다
  • git branch -rd origin/17W33 : 로컬에서 트랙킹 중인 리모트 브랜치 정보를 지운다. (리모트에서 브랜치가 지워진건 아니다)

Applying the changes from branch A to B, without merging or adding commits

git merge --no-commit --squash branchA
git reset HEAD # to unstage the changes

remote

  • git remote prune origin : remote 에서 삭제된 브랜치 삭제

log

  • git show --pretty="" --name-only 30e15fd5 : 수정된 파일 리스트만 표시
  • git logs 21.13.05..21.15.03: 특정 태그/브랜치 사이 log

complex command

  • git branch --merged | egrep -v "(^\*|release|develop)" | xargs git branch -d : merge 된 브랜치 삭제

Diff

  • How to compare files from two different branches?
    • git diff mybranch master -- myfile.cs
    • git diff mybranch..master -- myfile.cs
    • Git diff ..master path/to/file
  • 브랜치 사이에서 변경된 파일 리스트 보기
    • git diff --name-status release
  • 특정 브랜치의 파일로 바꾸기
    • git checkout {BRANCH} {FILE}

Submodule