#TIL #git 알아서 upstream을 설정해주는 push alias

[alias]
  pu = "!f() { \
         [[ $(git config \"branch.$(git symbolic-ref --short HEAD).merge\") = '' ]] && \
         git push -u origin $(git symbolic-ref --short HEAD) $@ || \
         git push $@; \
       }; f"

.gitconfig 파일에 추가한다. 커맨드라인 명령어로 추가하려고 했다. 에러 메시지가 뜨는데, 뭐가 문제인지 모르겠다. 에라이. 그냥 config 파일을 직접 수정했다.

두가지 전제 조건이 있다. remote는 origin 고정이다. remote와 local 브랜치 이름이 같다.

$ git checkout feature-1
$ git pu

feature-1 브랜치 upstream 저장소 설정 여부에 따라 둘 중 하나로 실행된다.

$ git push -u origin feature-1

또는

$ git push

참고

Feedback plz <3 @ohyecloudy, ohyecloudy@gmail.com

A Random Post