분산 버전 관리 시스템
.gitconfig 설정
[core]
autocrlf = input
editor = /usr/bin/vim
excludesfile = /home/user/.gitignore_global
[commit]
template = /home/user/.stCommitMsg
[merge]
branchdesc = true
commit = no
[pager]
branch = false
[alias]
# 브랜치 관리
br = branch -vv
brc = "!git branch --merged | egrep -v '(^\\*|master|main|dev)' | xargs git branch -d"
ch = "!git checkout $(git bselect)"
cur = "!git branch | awk '/^\\*/{print $2}'"
# 커밋/체크아웃
cm = commit
co = checkout
cp = cherry-pick
# 로그
l = log --graph --oneline --decorate --date=relative
ll = log --pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative
last = log -1 HEAD
# 상태
s = status -s
st = status
# 원격
fet = "!git fetch --all --prune --tags"
update = "!git fetch --all --prune; git merge origin"
[user]
name = Your Name
email = [email protected]
[init]
defaultBranch = mainTips
브랜치 이름 변경
git branch -m 변경전 변경후패스워드 초기화
git -c diff.mnemonicprefix=false \
-c core.quotepath=false \
-c credential.helper=sourcetree \
fetch --prune origin좋은 커밋 메시지 작성법
- 제목과 본문을 한 줄 띄워 분리
- 제목은 영문 기준 50자 이내
- 제목 첫 글자를 대문자로
- 제목 끝에
.금지 - 제목은 명령조로 (Add, Fix, Update, Remove 등)
- 본문은 영문 기준 72자마다 줄 바꾸기
- 본문은 어떻게보다 무엇을, 왜에 맞춰 작성
두 브랜치 간 커밋 비교 스크립트
#!/bin/sh
# git-diff.sh: 두 브랜치에 각각 존재하는 커밋 비교
BRANCH1=$1
BRANCH2=$2
if [ "$#" -ne 2 ]; then
echo "USAGE: ${0##*/} [BRANCH1] [BRANCH2]"
exit 1
fi
echo "Commits in ${BRANCH2} but not in ${BRANCH1}:"
git --no-pager log ${BRANCH1}..${BRANCH2} --oneline
echo
echo "Commits in ${BRANCH1} but not in ${BRANCH2}:"
git --no-pager log ${BRANCH2}..${BRANCH1} --oneline