Last active
December 13, 2023 08:05
-
-
Save datalater/2e89ff92c264f3ee3a5fed1e1385827e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
l = "log \ | |
--color --graph --decorate \ | |
--date=format:'%Y-%m-%d' \ | |
--abbrev-commit \ | |
--pretty=format:'%C(red)%h%C(auto)%d %s %C(magenta)(%cr)%C(bold green) %an'" | |
squash = "!f() { \ | |
# 인자($1)를 전달하지 않으면 경고 메시지를 출력합니다.;\n \ | |
if [ -z \"$1\" ]; then \ | |
echo 'Please provide the commit hash of the parent commit where other commits will be squashed into.'; \ | |
else \ | |
# 인자($1)로 전달한 부모 커밋부터 현재 브랜치(HEAD)의 모든 커밋 메시지를 가져옵니다.;\n \ | |
messages=$(git log --format=%B --reverse ${1}~..HEAD); \ | |
# 현재 브랜치를 인자($1)로 전달한 부모 커밋으로 되돌립니다. 이때 부모 커밋 이후의 모든 변경사항을 staging area에 추가합니다.;\n \ | |
git reset --soft ${1} && \ | |
# 가져온 커밋 메시지를 사용해서 현재 커밋에 덮어씌웁니다.;\n \ | |
echo \"${messages}\" | git commit --amend --allow-empty -F -; \ | |
fi; \ | |
unset -f f; \ | |
}; f" | |
# 기존 명령어 간소화 또는 일부 변경 | |
s = status | |
sw = switch | |
swc = switch -c | |
ac = "!git add --all && git commit -v" | |
amend = commit -a --amend --no-edit | |
precommit = commit --allow-empty -n | |
pushthis = push origin HEAD | |
# 추적하지 않는 파일도 포함해서 stash 하기 | |
stash = stash --include-untracked | |
# n번째 stash의 내용 확인하기 | |
stash-show = "!f() { git stash show -p --include-untracked \"${1:-0}\"; }; f" | |
# 현재 가리키고 있는 커밋 해시 출력 | |
hash = "!git rev-parse --short HEAD" | |
# 현재 체크아웃된 브랜치의 이름 출력 | |
head = !git rev-parse --abbrev-ref HEAD | |
# 현재 브랜치의 백업 브랜치 만들기 | |
bak = "!git switch -c \"bak/$(git head)\"" | |
# 백업 브랜치 일괄 삭제하기 | |
bak-clean = "!git for-each-ref refs/heads/bak --format='%(refname)' | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done" | |
# 동일한 이름의 로컬 브랜치를 원격 저장소와 동기화하기 | |
synchard = "!f() { git fetch --all && git checkout ${1:-main} && git reset --hard origin/${1:-main} && git switch - ; }; f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment