Git alias 설정

i33W·2024년 10월 4일

공통

~/.gitconfig git 전역 설정 파일 열기

code ~/.gitconfig

~/.gitconfig에 코드 추가하기


[alias]
  별칭  = "내용"
  

PR 쉽게 가져오기

[alias]
  pr  = "!f() { git fetch -fu ${2:-origin} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f"
  pr-clean = "!git for-each-ref refs/heads/pr/* --format='%(refname)' | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done"

1. pr: pr 새 브랜치로 가져오기

git pr [pr-num] [remote-name]

git pr 140				// remote 이름 생략하면 origin
git pr 140 upstream		// remote 이름 넣으면 그걸로 가져오고 pr/140 브랜치로 switch

2. pr-clean: pr 브랜치 정리

git pr-clean

예쁜 로그 출력

[alias]
  p-log = log --pretty=format:'%Cgreen%ad %Cred%h%Creset -%C(yellow)%d%Creset %s %C(bold blue)<%an>%Creset' --abbrev-commit --date=format:"%Y/%m/%d"

p-log

p-log [log 옵션]

git p-log
git p-log --since="3 weeks ago"
git p-log -n 10
profile
더 오래하면 돼.

0개의 댓글